chore(net): move CanRead helper out of CDataStore

This commit is contained in:
fallenoak 2025-09-23 20:31:08 -07:00
parent 4bd4868531
commit f5a0e009eb
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
4 changed files with 25 additions and 7 deletions

View File

@ -93,7 +93,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
msg.Get(generatorLen);
// TODO
// if (!msg.Sub8CBBF0(v31 + 1)) {
// if (!CanRead(msg, v31 + 1)) {
// return 0;
// }
@ -104,7 +104,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
msg.Get(largeSafePrimeLen);
// TODO
// if (!msg.sub_8CBBF0(v32 + 48)) {
// if (!CanRead(msg, v32 + 48)) {
// return 0;
// }
@ -118,7 +118,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), 16);
// TODO
// if (!msg.Sub8CBBF0(1)) {
// if (!CanRead(msg, 1)) {
// return 0;
// }
@ -139,7 +139,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
// PIN
if (logonFlags & 0x1) {
// TODO
// if (!msg.Sub8CBBF0(20)) {
// if (!CanRead(msg, 20) {
// return 0;
// }
@ -151,7 +151,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
if (logonFlags & 0x2) {
// TODO
/*
if (msg.Sub8CBBF0(12)) {
if (CanRead(msg, 12)) {
msg.Get(matrixWidth);
msg.Get(matrixHeight);
msg.Get(matrixDigitCount);
@ -170,7 +170,7 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
// TOKEN (authenticator)
if (logonFlags & 0x4) {
// TODO
// if (!msg.Sub8CBBF0(1)) {
// if (!CanRead(msg, 1)) {
// return 0;
// }

View File

@ -2,6 +2,7 @@
#define NET_GRUNT_COMMAND_HPP
#include "net/Grunt.hpp"
#include "net/grunt/Util.hpp"
template <class T>
class Grunt::Command {
@ -19,7 +20,7 @@ class Grunt::Command {
template <class T>
int32_t Grunt::Command<T>::Process(CDataStore& msg, Command<T>* commands, uint32_t commandCount, T& a4, uint32_t& pos) {
while (true) {
if (!msg.Sub8CBBF0(1)) {
if (!CanRead(msg, 1)) {
return 1;
}

7
src/net/grunt/Util.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "net/grunt/Util.hpp"
#include <common/DataStore.hpp>
// Invented name. Appears to be private to Grunt. Found at 8CBBF0 in 3.3.5a (Windows).
bool CanRead(const CDataStore& msg, uint32_t bytes) {
return msg.IsValid() && msg.Size() - msg.Tell() >= bytes;
}

10
src/net/grunt/Util.hpp Normal file
View File

@ -0,0 +1,10 @@
#ifndef NET_GRUNT_UTIL_HPP
#define NET_GRUNT_UTIL_HPP
#include <cstdint>
class CDataStore;
bool CanRead(const CDataStore& msg, uint32_t bytes);
#endif