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

Added Podium feature #3858

Merged
merged 11 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ enum PlayerFlags : uint64_t {
};

enum PodiumFlags : uint8_t {
PODIUM_SHOW_PLATFORM = 1 << 0, // show the platform below the outfit
PODIUM_SHOW_OUTFIT = 1 << 1, // show outfit
PODIUM_SHOW_MOUNT = 1 << 2 // show mount
PODIUM_SHOW_PLATFORM = 0, // show the platform below the outfit
PODIUM_SHOW_OUTFIT = 1, // show outfit
PODIUM_SHOW_MOUNT = 2 // show mount
};

enum ReloadTypes_t : uint8_t {
Expand Down
2 changes: 1 addition & 1 deletion src/podium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Podium::serializeAttr(PropWriteStream& propWriteStream) const
{
if (ATTR_PODIUMOUTFIT != 0) {
propWriteStream.write<uint8_t>(ATTR_PODIUMOUTFIT);
propWriteStream.write<uint8_t>(flags);
propWriteStream.write<uint8_t>(flags.to_ulong());
nekiro marked this conversation as resolved.
Show resolved Hide resolved
propWriteStream.write<uint8_t>(direction);
propWriteStream.write<uint16_t>(outfit.lookType);
propWriteStream.write<uint8_t>(outfit.lookHead);
Expand Down
26 changes: 15 additions & 11 deletions src/podium.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "item.h"

#include <bitset>

class Player;

class Podium final : public Item
Expand All @@ -39,37 +41,39 @@ class Podium final : public Item
Attr_ReadValue readAttr(AttrTypes_t attr, PropStream& propStream) override;
void serializeAttr(PropWriteStream& propWriteStream) const override;

void setOutfit(const Outfit_t& outfit) {
this->outfit = outfit;
void setOutfit(const Outfit_t& newOutfit) {
outfit = newOutfit;
}
const Outfit_t getOutfit() const {
return outfit;
}

bool hasFlag(PodiumFlags flag) const {
return (this->flags & flag) != 0;
return flags.test(flag);
}
void setFlagValue(PodiumFlags flag, bool value) {
if (value) {
this->flags |= flag;
return;
flags.set(flag);
} else {
flags.reset(flag);
}
this->flags &= ~flag;
}
void setFlags(uint8_t flags) {
this->flags = flags;
void setFlags(uint8_t newFlags) {
flags = newFlags;
}

const Direction getDirection() const {
return direction;
}
void setDirection(Direction direction) {
this->direction = direction;
void setDirection(Direction newDirection) {
direction = newDirection;
}

protected:
Outfit_t outfit;

private:
uint8_t flags = PODIUM_SHOW_PLATFORM; // show platform only
std::bitset<3> flags = { true }; // show platform only
Direction direction = DIRECTION_SOUTH;
};

Expand Down