summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game-server/character.cpp3
-rw-r--r--src/game-server/commandhandler.cpp6
-rw-r--r--src/game-server/gamehandler.cpp17
3 files changed, 21 insertions, 5 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 7e49f0ab..82bb6c5d 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -140,7 +140,8 @@ void CharacterComponent::deserialize(Entity &entity, MessageIn &msg)
unsigned id = msg.readInt16();
double base = msg.readDouble();
auto *attributeInfo = attributeManager->getAttributeInfo(id);
- beingComponent->setAttribute(entity, attributeInfo, base);
+ if (attributeInfo)
+ beingComponent->setAttribute(entity, attributeInfo, base);
}
// status effects currently affecting the character
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index ca08a636..79758bcf 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -1126,6 +1126,12 @@ static void handleAttribute(Entity *player, std::string &args)
auto *attribute = attributeManager->getAttributeInfo(attributeId);
+ if (!attribute)
+ {
+ say("Invalid attribute", player);
+ return;
+ }
+
// change the player's attribute
beingComponent->setAttribute(*other, attribute, value);
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index e1f58967..1a0ca158 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -879,8 +879,12 @@ void GameHandler::handleRaiseAttribute(GameClient &client, MessageIn &message)
const int attributeId = message.readInt16();
auto *attribute = attributeManager->getAttributeInfo(attributeId);
AttribmodResponseCode retCode;
- retCode = characterComponent->useCharacterPoint(*client.character,
- attribute);
+ if (attribute) {
+ retCode = characterComponent->useCharacterPoint(*client.character,
+ attribute);
+ } else {
+ retCode = ATTRIBMOD_INVALID_ATTRIBUTE;
+ }
MessageOut result(GPMSG_RAISE_ATTRIBUTE_RESPONSE);
result.writeInt8(retCode);
@@ -910,8 +914,13 @@ void GameHandler::handleLowerAttribute(GameClient &client, MessageIn &message)
const int attributeId = message.readInt32();
auto *attribute = attributeManager->getAttributeInfo(attributeId);
AttribmodResponseCode retCode;
- retCode = characterComponent->useCorrectionPoint(*client.character,
- attribute);
+
+ if (attribute) {
+ retCode = characterComponent->useCorrectionPoint(*client.character,
+ attribute);
+ } else {
+ retCode = ATTRIBMOD_INVALID_ATTRIBUTE;
+ }
MessageOut result(GPMSG_LOWER_ATTRIBUTE_RESPONSE);
result.writeInt8(retCode);