mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-09 23:06:47 +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,23 +18,40 @@ 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) {
|
||||
uint8_t cmd;
|
||||
msg.Get(cmd);
|
||||
while (true) {
|
||||
if (!msg.Sub8CBBF0(1)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < commandCount; i++) {
|
||||
auto& command = commands[i];
|
||||
uint8_t cmd;
|
||||
msg.Get(cmd);
|
||||
|
||||
if (command.cmd == cmd) {
|
||||
auto callback = command.callback;
|
||||
auto result = (a4.*callback)(msg);
|
||||
|
||||
if (result == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
// TODO
|
||||
return 0;
|
||||
Command<T>* command = nullptr;
|
||||
for (uint32_t i = 0; i < commandCount; i++) {
|
||||
if (commands[i].cmd == cmd) {
|
||||
command = &commands[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (!command) {
|
||||
// Bad command received [0x%02X] (unrecognized command)
|
||||
break;
|
||||
}
|
||||
|
||||
auto result = (a4.*command->callback)(msg);
|
||||
|
||||
if (result == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (result == 1) {
|
||||
// Bad command received [0x%02X] (Corrupt)
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == 2) {
|
||||
pos = msg.m_read;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
Loading…
Reference in New Issue
Block a user