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

feat: features OTCR natively in canary #3061

Open
wants to merge 71 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
4c54d85
1/6 feature: Creature : AttachedEffect, Shader
kokekanon Nov 4, 2024
745b7b8
2/7 feature: Map Shader
kokekanon Nov 4, 2024
ee26730
3/7 feature: TypingIcon
kokekanon Nov 5, 2024
23e166a
review: mehah
kokekanon Nov 5, 2024
eae4112
4/7 feature: Item Shader
kokekanon Nov 5, 2024
74ea55f
5/7 send disableFeature / enableFeature
kokekanon Nov 5, 2024
b09547e
review: dudantas
kokekanon Nov 5, 2024
9484492
fix sonarcloud bot
kokekanon Nov 5, 2024
f490ce4
fix sonarcloud bot 2
kokekanon Nov 5, 2024
1437b7e
fix: wrong review
dudantas Nov 5, 2024
67777a9
Code format - (Clang-format)
github-actions[bot] Nov 5, 2024
6766389
fix: itemShader old protocol otcr
kokekanon Nov 5, 2024
7c45b97
clean variable
kokekanon Nov 6, 2024
bd1854c
fix return get shader
kokekanon Nov 6, 2024
0ff915e
missing content player:getAttachedEffects
kokekanon Nov 6, 2024
f538950
simple test Talkations. delete when finished
kokekanon Nov 6, 2024
0217e80
Lua code format - (Stylua)
github-actions[bot] Nov 6, 2024
4b5fbad
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 6, 2024
9fe26c5
format
kokekanon Nov 6, 2024
7956f08
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 6, 2024
8d6961d
improve: variable name
kokekanon Nov 6, 2024
558b212
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Nov 6, 2024
3744f16
game_outfit functional version, not cleaned or optimized
kokekanon Nov 6, 2024
789354a
this requires review canary team .no break v8 and cipsoft
kokekanon Nov 7, 2024
6a23e40
Lua code format - (Stylua)
github-actions[bot] Nov 7, 2024
36da43e
fix: review sonarcloud ?
kokekanon Nov 7, 2024
8e939e5
Code format - (Clang-format)
github-actions[bot] Nov 7, 2024
c551152
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 7, 2024
5b5dc84
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Nov 7, 2024
9e763f7
simple test
kokekanon Nov 7, 2024
300f92c
Lua code format - (Stylua)
github-actions[bot] Nov 7, 2024
3bb868b
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 8, 2024
ef754d0
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Nov 8, 2024
6b27bb9
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 10, 2024
6097de3
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 10, 2024
ec0bd43
murge
kokekanon Nov 10, 2024
e30fd35
fix: compilation windows
kokekanon Nov 10, 2024
29919ed
Code format - (Clang-format)
github-actions[bot] Nov 10, 2024
6ed239c
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 13, 2024
2c46d0a
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 16, 2024
687d0b2
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 18, 2024
dce1886
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 25, 2024
f44bf10
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Nov 29, 2024
8350458
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Dec 12, 2024
4d85029
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Dec 27, 2024
95ef4e6
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Dec 31, 2024
00d22fc
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 1, 2025
d51e00a
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 2, 2025
2670848
Lua code format - (Stylua)
github-actions[bot] Jan 2, 2025
d35fa58
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 3, 2025
0d1e9a6
Merge branch 'kokekanon/all-feature-redemption' of https://github.com…
kokekanon Jan 3, 2025
f0dcf55
delete dev
kokekanon Jan 3, 2025
68514f8
fix: linux
kokekanon Jan 3, 2025
bbf7fcc
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 5, 2025
8a6e0fd
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 6, 2025
04c4906
fix: warning actions github linux
kokekanon Jan 6, 2025
4ed4295
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 7, 2025
3de9f82
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 9, 2025
f4ffffe
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 9, 2025
62f2531
review mehah: use std::vector
kokekanon Jan 9, 2025
d27ae12
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 10, 2025
c1f349e
review: dudantas part 1/2
kokekanon Jan 11, 2025
764af1b
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 12, 2025
73896db
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 12, 2025
da9effe
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 15, 2025
4570c59
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 15, 2025
7f4b8fa
fix
kokekanon Jan 15, 2025
2a1c35e
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 18, 2025
4c90473
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 21, 2025
6c2e645
Merge remote-tracking branch 'upstream/main' into kokekanon/all-featu…
kokekanon Jan 26, 2025
857f97d
fix: crash in last appearance attachedeffects on debug compilation 3284
kokekanon Jan 26, 2025
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
4 changes: 2 additions & 2 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,15 +2004,15 @@ void Creature::sendAsyncTasks() {
}

void Creature::attachEffectById(uint16_t id) {
auto it = std::find(attachedEffectList.begin(), attachedEffectList.end(), id);
auto it = std::ranges::find(attachedEffectList, id);
if (it != attachedEffectList.end()) {
return;
}
attachedEffectList.push_back(id);
g_game().sendAttachedEffect(static_self_cast<Creature>(), id);
}
void Creature::detachEffectById(uint16_t id) {
auto it = std::find(attachedEffectList.begin(), attachedEffectList.end(), id);
auto it = std::ranges::find(attachedEffectList, id);
if (it == attachedEffectList.end()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/creature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ class Creature : virtual public Thing, public SharedObject {
std::string getShader() const {
return shader;
}
void setShader(const std::string &shaderName) {
void setShader(const std::string_view &shaderName) {
majestyotbr marked this conversation as resolved.
Show resolved Hide resolved
shader = shaderName;
}
void attachEffectById(uint16_t id);
Expand Down
27 changes: 13 additions & 14 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9578,10 +9578,9 @@ void Player::sendAttachedEffect(const std::shared_ptr<Creature> &creature, uint1
if (!client || !creature) {
return;
}

if (creature->getPlayer()) {
kokekanon marked this conversation as resolved.
Show resolved Hide resolved
if (client) {
client->sendAttachedEffect(creature, effectId);
}
client->sendAttachedEffect(creature, effectId);
}
}

Expand All @@ -9590,33 +9589,33 @@ void Player::sendDetachEffect(const std::shared_ptr<Creature> &creature, uint16_
return;
}
if (creature->getPlayer()) {
if (client) {
client->sendDetachEffect(creature, effectId);
}
client->sendDetachEffect(creature, effectId);
}
}

void Player::sendShader(const std::shared_ptr<Creature> &creature, const std::string &shaderName) const {
void Player::sendShader(const std::shared_ptr<Creature> &creature, const std::string_view &shaderName) const {
if (!client || !creature) {
return;
}
if (creature->getPlayer()) {
if (client) {
client->sendShader(creature, shaderName);
}
}
}

void Player::sendMapShader(const std::string &shaderName) const {
if (client) {
client->sendMapShader(shaderName);
void Player::sendMapShader(const std::string_view &shaderName) const {
if (!client) {
return;
}

client->sendMapShader(shaderName);
}

void Player::sendPlayerTyping(const std::shared_ptr<Creature> &creature, uint8_t typing) const {
if (client) {
client->sendPlayerTyping(creature, typing);
if (!client) {
return;
}

client->sendPlayerTyping(creature, typing);
}

void Player::sendSingleSoundEffect(const Position &pos, SoundEffect_t id, SourceEffect_t source) const {
Expand Down
10 changes: 5 additions & 5 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,12 +1264,12 @@ class Player final : public Creature, public Cylinder, public Bankable {

void sendAttachedEffect(const std::shared_ptr<Creature> &creature, uint16_t effectId) const;
void sendDetachEffect(const std::shared_ptr<Creature> &creature, uint16_t effectId) const;
void sendShader(const std::shared_ptr<Creature> &creature, const std::string &shaderName) const;
void sendMapShader(const std::string &shaderName) const;
const std::string &getMapShader() const {
void sendShader(const std::shared_ptr<Creature> &creature, const std::string_view &shaderName) const;
void sendMapShader(const std::string_view &shaderName) const;
const std::string_view &getMapShader() const {
return mapShader;
}
void setMapShader(const std::string &shaderName) {
void setMapShader(const std::string_view &shaderName) {
this->mapShader = shaderName;
}
void sendPlayerTyping(const std::shared_ptr<Creature> &creature, uint8_t typing) const;
Expand Down Expand Up @@ -1383,7 +1383,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
std::string name;
std::string guildNick;
std::string loyaltyTitle;
std::string mapShader;
std::string_view mapShader;
majestyotbr marked this conversation as resolved.
Show resolved Hide resolved

Skill skills[SKILL_LAST + 1];
LightInfo itemsLight;
Expand Down
9 changes: 5 additions & 4 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10856,25 +10856,27 @@ void Game::updatePlayersOnline() const {
void Game::sendAttachedEffect(const std::shared_ptr<Creature> &creature, uint16_t effectId) {
auto spectators = Spectators().find<Player>(creature->getPosition(), true);
for (const auto &spectator : spectators) {
auto player = spectator->getPlayer();
const auto &player = spectator->getPlayer();
if (player) {
player->sendAttachedEffect(creature, effectId);
}
}
}

void Game::sendDetachEffect(const std::shared_ptr<Creature> &creature, uint16_t effectId) {
auto spectators = Spectators().find<Player>(creature->getPosition(), true);
for (const auto &spectator : spectators) {
auto player = spectator->getPlayer();
const auto &player = spectator->getPlayer();
if (player) {
player->sendDetachEffect(creature, effectId);
}
}
}

void Game::updateCreatureShader(const std::shared_ptr<Creature> &creature) {
auto spectators = Spectators().find<Player>(creature->getPosition(), true);
for (const auto &spectator : spectators) {
auto player = spectator->getPlayer();
const auto &player = spectator->getPlayer();
if (player) {
player->sendShader(creature, creature->getShader());
}
Expand All @@ -10886,7 +10888,6 @@ void Game::playerSetTyping(uint32_t playerId, uint8_t typing) {
if (!player) {
return;
}

for (const auto &spectator : Spectators().find<Player>(player->getPosition(), true)) {
if (const auto &tmpPlayer = spectator->getPlayer()) {
tmpPlayer->sendPlayerTyping(player, typing);
Expand Down
6 changes: 3 additions & 3 deletions src/items/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,20 @@ class ItemProperties {
return getCorpseOwner() == static_cast<uint32_t>(std::numeric_limits<int32_t>::max());
}

void setShader(const std::string &shaderName) {
void setShader(const std::string_view &shaderName) {
if (shaderName.empty()) {
removeCustomAttribute("shader");
return;
}

setCustomAttribute("shader", shaderName);
setCustomAttribute("shader", std::string(shaderName)); // temp
}

bool hasShader() const {
return getCustomAttribute("shader") != nullptr;
}

std::string getShader() const {
std::string_view getShader() const {
const CustomAttribute* shader = getCustomAttribute("shader");
return shader ? shader->getString() : "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/lua/functions/creatures/player/player_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4472,7 +4472,7 @@ int PlayerFunctions::luaPlayerGetMapShader(lua_State* L) {
return 0;
}

pushString(L, player->getMapShader());
pushString(L, std::string(player->getMapShader())); // temp
return 1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/lua/functions/items/item_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ int ItemFunctions::luaItemGetShader(lua_State* L) {
return 1;
}

pushString(L, item->getShader());
pushString(L, std::string(item->getShader())); // temp
return 1;
}

Expand All @@ -1076,6 +1076,7 @@ int ItemFunctions::luaItemSetShader(lua_State* L) {
}

item->setShader(getString(L, 2));
g_game().refreshItem(item);
pushBoolean(L, true);
return 1;
}
12 changes: 6 additions & 6 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void ProtocolGame::AddItem(NetworkMessage &msg, const std::shared_ptr<Item> &ite

// OTCR Features
if (isOTC && otclientV8 == 0) {
msg.addString(item->getShader());
msg.addString(std::string(item->getShader())); // temp
}
}

Expand Down Expand Up @@ -9320,7 +9320,7 @@ void ProtocolGame::sendAttachedEffect(const std::shared_ptr<Creature> &creature,
return;
}

NetworkMessage msg;
NetworkMessage msg;
msg.addByte(0x34);
msg.add<uint32_t>(creature->getID());
msg.add<uint16_t>(effectId);
Expand All @@ -9339,24 +9339,24 @@ void ProtocolGame::sendDetachEffect(const std::shared_ptr<Creature> &creature, u
writeToOutputBuffer(msg);
}

void ProtocolGame::sendShader(const std::shared_ptr<Creature> &creature, const std::string &shaderName) {
void ProtocolGame::sendShader(const std::shared_ptr<Creature> &creature, const std::string_view &shaderName) {
if (!isOTC || player->getOperatingSystem() >= CLIENTOS_OTCLIENTV8_LINUX) {
return;
}
NetworkMessage msg;
msg.addByte(0x36);
msg.add<uint32_t>(creature->getID());
msg.addString(shaderName);
msg.addString(std::string(shaderName)); // temp
writeToOutputBuffer(msg);
}

void ProtocolGame::sendMapShader(const std::string &shaderName) {
void ProtocolGame::sendMapShader(const std::string_view &shaderName) {
if (!isOTC || player->getOperatingSystem() >= CLIENTOS_OTCLIENTV8_LINUX) {
return;
}
NetworkMessage msg;
msg.addByte(0x37);
msg.addString(shaderName);
msg.addString(std::string(shaderName)); // temp
writeToOutputBuffer(msg);
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/network/protocol/protocolgame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ class ProtocolGame final : public Protocol {
void sendOTCRFeatures();
void sendAttachedEffect(const std::shared_ptr<Creature> &creature, uint16_t effectId);
void sendDetachEffect(const std::shared_ptr<Creature> &creature, uint16_t effectId);
void sendShader(const std::shared_ptr<Creature> &creature, const std::string &shaderName);
void sendMapShader(const std::string &shaderName);
void sendShader(const std::shared_ptr<Creature> &creature, const std::string_view &shaderName);
void sendMapShader(const std::string_view &shaderName);
void sendPlayerTyping(const std::shared_ptr<Creature> &creature, uint8_t typing);
void parsePlayerTyping(NetworkMessage &msg);

Expand Down
Loading