Skip to content

Commit cb20b99

Browse files
committed
feat(scripting/usermessages): Bytes
1 parent 9e220c9 commit cb20b99

File tree

3 files changed

+182
-96
lines changed

3 files changed

+182
-96
lines changed

src/network/usermessages/usermessage.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,50 @@ void UserMessage::AddQAngle(std::string pszFieldName, QAngle& vec)
816816
msgAng->set_z(vec.z);
817817
}
818818

819+
std::string UserMessage::GetBytes(std::string pszFieldName)
820+
{
821+
GETCHECK_FIELD("");
822+
CHECK_FIELD_TYPE(STRING, "");
823+
CHECK_FIELD_NOT_REPEATED("");
824+
825+
return this->msgBuffer->GetReflection()->GetString(*this->msgBuffer, field);
826+
}
827+
828+
void UserMessage::SetBytes(std::string pszFieldName, std::string& value)
829+
{
830+
GETCHECK_FIELD();
831+
CHECK_FIELD_TYPE_VOID(STRING);
832+
CHECK_FIELD_NOT_REPEATED();
833+
834+
this->msgBuffer->GetReflection()->SetString(this->msgBuffer, field, value);
835+
}
836+
std::string UserMessage::GetRepeatedBytes(std::string pszFieldName, int index)
837+
{
838+
GETCHECK_FIELD("");
839+
CHECK_FIELD_TYPE(STRING, "");
840+
CHECK_FIELD_REPEATED("");
841+
CHECK_REPEATED_ELEMENT(index, "");
842+
843+
return this->msgBuffer->GetReflection()->GetRepeatedString(*this->msgBuffer, field, index);
844+
}
845+
void UserMessage::SetRepeatedBytes(std::string pszFieldName, int index, std::string& value)
846+
{
847+
GETCHECK_FIELD();
848+
CHECK_FIELD_TYPE_VOID(STRING);
849+
CHECK_FIELD_REPEATED();
850+
CHECK_REPEATED_ELEMENT_VOID(index);
851+
852+
this->msgBuffer->GetReflection()->SetRepeatedString(this->msgBuffer, field, index, value);
853+
}
854+
void UserMessage::AddBytes(std::string pszFieldName, std::string& value)
855+
{
856+
GETCHECK_FIELD();
857+
CHECK_FIELD_TYPE_VOID(STRING);
858+
CHECK_FIELD_REPEATED();
859+
860+
this->msgBuffer->GetReflection()->AddString(this->msgBuffer, field, value);
861+
}
862+
819863
UserMessage UserMessage::GetUMessage(std::string pszFieldName)
820864
{
821865
GETCHECK_FIELD(UserMessage(""));

src/network/usermessages/usermessage.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ class UserMessage
112112
void SetRepeatedQAngle(std::string pszFieldName, int index, QAngle& vec);
113113
void AddQAngle(std::string pszFieldName, QAngle& vec);
114114

115+
std::string GetBytes(std::string pszFieldName);
116+
void SetBytes(std::string pszFieldName, std::string& value);
117+
std::string GetRepeatedBytes(std::string pszFieldName, int index);
118+
void SetRepeatedBytes(std::string pszFieldName, int index, std::string& value);
119+
void AddBytes(std::string pszFieldName, std::string& value);
120+
115121
UserMessage GetUMessage(std::string pszFieldName);
116122
UserMessage GetRepeatedMessage(std::string pszFieldName, int index);
117123
UserMessage AddMessage(std::string pszFieldName);

0 commit comments

Comments
 (0)