mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 02:08:20 +00:00
a2ca273370
* Add failArmor server side Address out of bounds reading in behavior Address the basicAttackBehavior reading out of bounds memory and reading bits that didnt exist, which occasionally caused crashes and also caused the behavior to do undefined behavior due to the bad reads. Tested that attacking a wall anywhere with a projectile now does not crash the game. Tested with logs that the behavior correctly returned when there were no allocated bits or returned when other states were met. Add back logs and add fail handle Remove comment block Revert "Add back logs and add fail handle" This reverts commit db19be0906fc8bf35bf89037e2bfba39f5ef9c0c. Split out checks * Cleanup Behavior streams
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
#include "MovementSwitchBehavior.h"
|
|
#include "BehaviorBranchContext.h"
|
|
#include "Game.h"
|
|
#include "dLogger.h"
|
|
|
|
void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
|
if (this->m_groundAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
|
this->m_jumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
|
this->m_fallingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
|
this->m_doubleJumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
|
this->m_airAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
|
this->m_jetpackAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
|
return;
|
|
}
|
|
|
|
uint32_t movementType{};
|
|
if (!bitStream->Read(movementType)) {
|
|
Game::logger->Log("MovementSwitchBehavior", "Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
|
return;
|
|
};
|
|
|
|
switch (movementType) {
|
|
case 1:
|
|
this->m_groundAction->Handle(context, bitStream, branch);
|
|
break;
|
|
case 2:
|
|
this->m_jumpAction->Handle(context, bitStream, branch);
|
|
break;
|
|
case 3:
|
|
this->m_fallingAction->Handle(context, bitStream, branch);
|
|
break;
|
|
case 4:
|
|
this->m_doubleJumpAction->Handle(context, bitStream, branch);
|
|
break;
|
|
case 5:
|
|
this->m_airAction->Handle(context, bitStream, branch);
|
|
break;
|
|
case 6:
|
|
this->m_jetpackAction->Handle(context, bitStream, branch);
|
|
break;
|
|
default:
|
|
Game::logger->Log("MovementSwitchBehavior", "Invalid movement behavior type (%i)!", movementType);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void MovementSwitchBehavior::Load() {
|
|
this->m_airAction = GetAction("air_action");
|
|
|
|
this->m_doubleJumpAction = GetAction("double_jump_action");
|
|
|
|
this->m_fallingAction = GetAction("falling_action");
|
|
|
|
this->m_groundAction = GetAction("ground_action");
|
|
|
|
this->m_jetpackAction = GetAction("jetpack_action");
|
|
|
|
this->m_jumpAction = GetAction("jump_action");
|
|
}
|