mirror of
https://github.com/Squareville/wonderland-server.git
synced 2025-12-16 12:33:52 -06:00
Merge branch 'main' of github.com:DarkflameUniverse/DarkflameServer into DarkflameUniverse-main
This commit is contained in:
@@ -96,3 +96,17 @@ bool Logger::GetLogToConsole() const {
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
FuncEntry::FuncEntry(const char* funcName, const char* fileName, const uint32_t line) {
|
||||
m_FuncName = funcName;
|
||||
if (!m_FuncName) m_FuncName = "Unknown";
|
||||
m_Line = line;
|
||||
m_FileName = fileName;
|
||||
LOG("--> %s::%s:%i", m_FileName, m_FuncName, m_Line);
|
||||
}
|
||||
|
||||
FuncEntry::~FuncEntry() {
|
||||
if (!m_FuncName || !m_FileName) return;
|
||||
|
||||
LOG("<-- %s::%s:%i", m_FileName, m_FuncName, m_Line);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,19 @@ constexpr const char* GetFileNameFromAbsolutePath(const char* path) {
|
||||
#define LOG(message, ...) do { auto str_ = FILENAME_AND_LINE; Game::logger->Log(str_, message, ##__VA_ARGS__); } while(0)
|
||||
#define LOG_DEBUG(message, ...) do { auto str_ = FILENAME_AND_LINE; Game::logger->LogDebug(str_, message, ##__VA_ARGS__); } while(0)
|
||||
|
||||
// Place this right at the start of a function. Will log a message when called and then once you leave the function.
|
||||
#define LOG_ENTRY auto str_ = GetFileNameFromAbsolutePath(__FILE__); FuncEntry funcEntry_(__FUNCTION__, str_, __LINE__)
|
||||
|
||||
class FuncEntry {
|
||||
public:
|
||||
FuncEntry(const char* funcName, const char* fileName, const uint32_t line);
|
||||
~FuncEntry();
|
||||
private:
|
||||
const char* m_FuncName = nullptr;
|
||||
const char* m_FileName = nullptr;
|
||||
uint32_t m_Line = 0;
|
||||
};
|
||||
|
||||
// Writer class for writing data to files.
|
||||
class Writer {
|
||||
public:
|
||||
|
||||
@@ -10,7 +10,9 @@ void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream,
|
||||
}
|
||||
|
||||
void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) {
|
||||
LOG_ENTRY;
|
||||
for (auto* behavior : this->m_behaviors) {
|
||||
LOG("%i calculating %i", m_behaviorId, behavior->GetBehaviorID());
|
||||
behavior->Calculate(context, bitStream, branch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,4 +95,6 @@ public:
|
||||
|
||||
Behavior& operator=(const Behavior& other) = default;
|
||||
Behavior& operator=(Behavior&& other) = default;
|
||||
|
||||
uint32_t GetBehaviorID() const { return m_behaviorId; }
|
||||
};
|
||||
|
||||
@@ -183,12 +183,11 @@ void PropertyBehavior::Update(float deltaTime, ModelComponent& modelComponent) {
|
||||
UpdateResult updateResult{};
|
||||
activeState.Update(deltaTime, modelComponent, updateResult);
|
||||
if (updateResult.newState.has_value() && updateResult.newState.value() != m_ActiveState) {
|
||||
LOG("Behavior %llu is changing from state %s to %s", StringifiedEnum::ToString(m_ActiveState).data(), StringifiedEnum::ToString(updateResult.newState.value()).data());
|
||||
LOG("Behavior %llu is changing from state %s to %s", m_BehaviorId, StringifiedEnum::ToString(m_ActiveState).data(), StringifiedEnum::ToString(updateResult.newState.value()).data());
|
||||
GameMessages::ResetModelToDefaults resetMsg{};
|
||||
resetMsg.bResetPos = false;
|
||||
resetMsg.bResetRot = false;
|
||||
resetMsg.bUnSmash = false;
|
||||
resetMsg.bResetBehaviors = false;
|
||||
modelComponent.OnResetModelToDefaults(resetMsg);
|
||||
HandleMsg(resetMsg);
|
||||
m_ActiveState = updateResult.newState.value();
|
||||
|
||||
@@ -376,6 +376,9 @@ void DropLoot(Entity* player, const LWOOBJID source, const std::map<LOT, LootDro
|
||||
|
||||
// Filter out dead player if we need to
|
||||
std::vector<LWOOBJID> lootEarners;
|
||||
// Coin roll is divided up between the members, rounded up, then dropped for each player
|
||||
const uint32_t coinRoll = static_cast<uint32_t>(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
|
||||
const auto droppedCoins = team ? std::ceil(static_cast<float>(coinRoll) / team->members.size()) : coinRoll;
|
||||
if (team) {
|
||||
if (noTeamLootOnDeath) {
|
||||
for (const auto member : team->members) {
|
||||
|
||||
Reference in New Issue
Block a user