Fixed crash when zooming in very fast on network

This commit is contained in:
Yousef Khadadeh 2025-09-30 16:48:12 +03:00
parent 2f758cf4e2
commit 08c6930c48
2 changed files with 6 additions and 4 deletions

View file

@ -57,4 +57,4 @@ enum ClientCommands : MessageCommandType {
#define VERSION_STRING "0.2.0" #define VERSION_STRING "0.2.0"
// Arbitrary value. Higher scale up values lead to less scale up events (which can cause stuttering), but leads to larger numbers overall, which can cause a tiny bit of lag and increased memory usage // Arbitrary value. Higher scale up values lead to less scale up events (which can cause stuttering), but leads to larger numbers overall, which can cause a tiny bit of lag and increased memory usage
#define CANVAS_SCALE_UP_STEP WorldScalar("100000000000000000000000000000000000000000000000000") #define CANVAS_SCALE_UP_STEP WorldScalar("2")

View file

@ -122,9 +122,11 @@ void World::init_client_callbacks() {
con.client_add_recv_callback(CLIENT_CANVAS_SCALE, [&](cereal::PortableBinaryInputArchive& message) { con.client_add_recv_callback(CLIENT_CANVAS_SCALE, [&](cereal::PortableBinaryInputArchive& message) {
uint64_t newCanvasScale; uint64_t newCanvasScale;
message(newCanvasScale); message(newCanvasScale);
con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_CANVAS_SCALE, newCanvasScale); if(newCanvasScale > canvasScale) {
scale_up(FixedPoint::pow_int(CANVAS_SCALE_UP_STEP, newCanvasScale - canvasScale)); con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_CANVAS_SCALE, newCanvasScale);
canvasScale = newCanvasScale; scale_up(FixedPoint::pow_int(CANVAS_SCALE_UP_STEP, newCanvasScale - canvasScale));
canvasScale = newCanvasScale;
}
}); });
con.client_add_recv_callback(CLIENT_KEEP_ALIVE, [&](cereal::PortableBinaryInputArchive& message) { con.client_add_recv_callback(CLIENT_KEEP_ALIVE, [&](cereal::PortableBinaryInputArchive& message) {
}); });