Skip to content

Commit

Permalink
tweak(onesync): add max net game event retries to client
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianTerhorst committed Oct 14, 2024
1 parent 72c2081 commit c90f7da
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NetGameEventV2PacketHandler : public net::PacketHandler<net::packet::Serve
return;
}

rage::HandleNetGameEventV2(serverNetGameEventV2);
rage::HandleNetGameEventV2(serverNetGameEventV2, 0);
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion code/components/gta-net-five/include/netGameEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,5 @@ namespace rage
CNetGamePlayer* GetPlayer31();

static void HandleNetGameEvent(const char* idata, size_t len);
static void HandleNetGameEventV2(net::packet::ServerNetGameEventV2& serverNetGameEventV2);
static void HandleNetGameEventV2(net::packet::ServerNetGameEventV2& serverNetGameEventV2, uint8_t retries);
}
18 changes: 13 additions & 5 deletions code/components/gta-net-five/src/netGameEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ struct ReEventQueueItem
uint16_t eventId;
bool isReply;
std::vector<uint8_t> eventData;
uint8_t retries;

ReEventQueueItem(net::packet::ServerNetGameEventV2& serverNetGameEvent):
ReEventQueueItem(net::packet::ServerNetGameEventV2& serverNetGameEvent, uint8_t retries):
eventNameHash(serverNetGameEvent.eventNameHash),
clientNetId(serverNetGameEvent.clientNetId),
eventId(serverNetGameEvent.eventId),
isReply(serverNetGameEvent.isReply),
eventData(serverNetGameEvent.data.GetValue().begin(), serverNetGameEvent.data.GetValue().end())
eventData(serverNetGameEvent.data.GetValue().begin(), serverNetGameEvent.data.GetValue().end()),
retries(retries)
{

}
Expand Down Expand Up @@ -543,13 +545,18 @@ void rage::HandleNetGameEvent(const char* idata, size_t len)
}
}

void rage::HandleNetGameEventV2(net::packet::ServerNetGameEventV2& serverNetGameEventV2)
void rage::HandleNetGameEventV2(net::packet::ServerNetGameEventV2& serverNetGameEventV2, uint8_t retries)
{
if (!icgi->HasVariable("networkInited"))
{
return;
}

if (retries > 100)
{
return;
}

// TODO: use a real player for some things that _are_ 32-safe
rage::EnsurePlayer31();

Expand Down Expand Up @@ -641,7 +648,7 @@ void rage::HandleNetGameEventV2(net::packet::ServerNetGameEventV2& serverNetGame

if (rejected)
{
g_reEventQueueV2.emplace_back(serverNetGameEventV2);
g_reEventQueueV2.emplace_back(serverNetGameEventV2, retries + 1);
}
}
}
Expand Down Expand Up @@ -1167,7 +1174,7 @@ namespace rage
serverNetGameEvent.isReply = g_reEventQueueV2.front().isReply;
serverNetGameEvent.data = {g_reEventQueueV2.front().eventData.data(), g_reEventQueueV2.front().eventData.size()};

HandleNetGameEventV2(serverNetGameEvent);
HandleNetGameEventV2(serverNetGameEvent, g_reEventQueueV2.front().retries);

g_reEventQueueV2.pop_front();
}
Expand Down Expand Up @@ -1235,6 +1242,7 @@ static InitFunction initFunction([]()
g_events.clear();
g_eventsV2.clear();
g_reEventQueue.clear();
g_reEventQueueV2.clear();
});
});

Expand Down

0 comments on commit c90f7da

Please sign in to comment.