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: parse creature data in protocolgame #800

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/client/protocolcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace Proto
GameServerMissleEffect = 133, // Anthem on 13.x
GameServerItemClasses = 134,
GameServerTrappers = 135,
GameServerCreatureData = 139,
GameServerCreatureHealth = 140,
GameServerCreatureLight = 141,
GameServerCreatureOutfit = 142,
Expand Down
2 changes: 2 additions & 0 deletions src/client/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class ProtocolGame : public Protocol
void parseItemClasses(const InputMessagePtr& msg);
void parseCreatureMark(const InputMessagePtr& msg);
void parseTrappers(const InputMessagePtr& msg);
void addCreatureIcon(const InputMessagePtr& msg, const CreaturePtr& creature);
void parseCreatureData(const InputMessagePtr& msg);
void parseCreatureHealth(const InputMessagePtr& msg);
void parseCreatureLight(const InputMessagePtr& msg);
void parseCreatureOutfit(const InputMessagePtr& msg) const;
Expand Down
43 changes: 43 additions & 0 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@
case Proto::GameServerTrappers:
parseTrappers(msg);
break;
case Proto::GameServerCreatureData:
parseCreatureData(msg);
break;
case Proto::GameServerCreatureHealth:
parseCreatureHealth(msg);
break;
Expand Down Expand Up @@ -1554,6 +1557,46 @@
}
}

void ProtocolGame::addCreatureIcon(const InputMessagePtr& msg, const CreaturePtr& creature) {

Check warning on line 1560 in src/client/protocolgameparse.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

unused parameter ‘creature’ [-Wunused-parameter]

Check warning on line 1560 in src/client/protocolgameparse.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

unused parameter ‘creature’ [-Wunused-parameter]
const uint8_t sizeIcons = msg->getU8();
for (auto i = 0; i < sizeIcons; ++i) {
msg->getU8(); // icon.serialize()
msg->getU8(); // icon.category
msg->getU16(); // icon.count
}

// TODO: implement creature icons usage
}

void ProtocolGame::parseCreatureData(const InputMessagePtr& msg)
{
const uint32_t id = msg->getU32();
const uint8_t type = msg->getU8();

const auto& creature = g_map.getCreatureById(id);
if (!creature) {
g_logger.traceError(stdext::format("ProtocolGame::parseCreatureData: could not get creature with id %d", id));
}

switch (type) {
case 0: // creature update
getCreature(msg);
break;
case 11: // creature mana percent
msg->getU8();
break;
case 12: // creature show status
msg->getU8();
break;
case 13: // player vocation
msg->getU8();
break;
case 14: // creature icons
addCreatureIcon(msg, creature);
break;
}
}

void ProtocolGame::parseCreatureHealth(const InputMessagePtr& msg)
{
const uint32_t id = msg->getU32();
Expand Down
Loading