mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-10 11:25:59 +03:00
feat(net): add loop to grunt command processing
This commit is contained in:
parent
27e0190fb9
commit
e16e5605ba
@ -1 +1 @@
|
|||||||
Subproject commit 5dce613aeb790c30d02c222444d0379e4619c184
|
Subproject commit 9a5e71de2207be9368428a3bff147b9bcd51d94a
|
||||||
@ -18,22 +18,39 @@ class Grunt::Command {
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
int32_t Grunt::Command<T>::Process(CDataStore& msg, Command<T>* commands, uint32_t commandCount, T& a4, uint32_t& pos) {
|
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)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
msg.Get(cmd);
|
msg.Get(cmd);
|
||||||
|
|
||||||
|
Command<T>* command = nullptr;
|
||||||
for (uint32_t i = 0; i < commandCount; i++) {
|
for (uint32_t i = 0; i < commandCount; i++) {
|
||||||
auto& command = commands[i];
|
if (commands[i].cmd == cmd) {
|
||||||
|
command = &commands[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (command.cmd == cmd) {
|
if (!command) {
|
||||||
auto callback = command.callback;
|
// Bad command received [0x%02X] (unrecognized command)
|
||||||
auto result = (a4.*callback)(msg);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = (a4.*command->callback)(msg);
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
// TODO
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result == 1) {
|
||||||
|
// Bad command received [0x%02X] (Corrupt)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == 2) {
|
||||||
|
pos = msg.m_read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user