IDs are no longer generated on server, fixes error caused by spamming undo and redo

This commit is contained in:
Yousef Khadadeh 2025-08-27 11:38:36 +03:00
parent a9af3a9b17
commit 57392cdfdd
12 changed files with 92 additions and 108 deletions

View file

@ -81,7 +81,7 @@ void DrawBrushStroke::draw(SkCanvas* canvas, const DrawData& drawData) {
canvas->save();
paint.setColor4f(SkColor4f{d->color.x(), d->color.y(), d->color.z(), d->color.w()});
canvas_do_calculated_transform(canvas);
if(drawSetupData.mipmapLevel == 0)
if(drawSetupData.mipmapLevel == 0 || drawData.dontUseDrawProgCache) // check dontUseDrawProgCache, to make sure that SVG screenshots dont use LOD
canvas->drawPath(*brushPath, paint);
else
canvas->drawPath(*brushPathLOD[drawSetupData.mipmapLevel - 1], paint);

View file

@ -16,14 +16,14 @@
void save(cereal::PortableBinaryOutputArchive& a, const CollabListType::ObjectInfo& o) {
// Client will send ID, but server should ignore ID and generate its own
a(o.pos, o.obj->get_type(), o.id, o.obj->coords, *o.obj);
a(o.pos, o.obj->get_type(), o.obj->id, o.obj->coords, *o.obj);
}
void load(cereal::PortableBinaryInputArchive& a, CollabListType::ObjectInfo& o) {
DrawComponentType t;
a(o.pos, t, o.id);
a(o.pos, t);
o.obj = DrawComponent::allocate_comp_type(t);
a(o.obj->coords, *o.obj);
a(o.obj->id, o.obj->coords, *o.obj);
}
void SendOrderedComponentVectorOp::save(cereal::PortableBinaryOutputArchive& a) const {
@ -60,7 +60,7 @@ void DrawComponent::server_send_place_many(MainServer& server, std::vector<Colla
server.netServer->send_items_to_all_clients(RELIABLE_COMMAND_CHANNEL, CLIENT_PLACE_MANY_COMPONENTS, SendOrderedComponentVectorOp{&comps});
}
void DrawComponent::server_send_place(MainServer& server, ServerClientID id, uint64_t placement) {
void DrawComponent::server_send_place(MainServer& server, uint64_t placement) {
server.netServer->send_items_to_all_clients(RELIABLE_COMMAND_CHANNEL, CLIENT_PLACE_SINGLE_COMPONENT, placement, get_type(), id, this->coords, *this);
}
@ -72,7 +72,7 @@ void DrawComponent::server_send_erase_set(MainServer& server, const std::unorder
server.netServer->send_items_to_all_clients(RELIABLE_COMMAND_CHANNEL, CLIENT_ERASE_MANY_COMPONENTS, ids);
}
void DrawComponent::server_send_update(MainServer& server, ServerClientID id) {
void DrawComponent::server_send_update(MainServer& server) {
server.netServer->send_items_to_all_clients(UNRELIABLE_COMMAND_CHANNEL, CLIENT_UPDATE_COMPONENT, id, *this);
}
@ -130,12 +130,12 @@ void DrawComponent::client_send_place_many(DrawingProgram& drawP, std::vector<Co
void DrawComponent::client_send_place(DrawingProgram& drawP) {
//if(collabListInfo.lock()) If this fails, then there's a real issue
drawP.world.con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_PLACE_SINGLE_COMPONENT, collabListInfo.lock()->pos, get_type(), this->coords, *this);
drawP.world.con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_PLACE_SINGLE_COMPONENT, collabListInfo.lock()->pos, get_type(), id, this->coords, *this);
}
void DrawComponent::client_send_update(DrawingProgram& drawP) {
if(collabListInfo.lock())
drawP.world.con.client_send_items_to_server(UNRELIABLE_COMMAND_CHANNEL, SERVER_UPDATE_COMPONENT, collabListInfo.lock()->id, *this);
drawP.world.con.client_send_items_to_server(UNRELIABLE_COMMAND_CHANNEL, SERVER_UPDATE_COMPONENT, id, *this);
}
void DrawComponent::client_send_transform_many(DrawingProgram& drawP, const std::vector<std::pair<ServerClientID, CoordSpaceHelper>>& transforms) {
@ -144,7 +144,7 @@ void DrawComponent::client_send_transform_many(DrawingProgram& drawP, const std:
void DrawComponent::client_send_erase(DrawingProgram& drawP) {
if(collabListInfo.lock())
drawP.world.con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_ERASE_SINGLE_COMPONENT, collabListInfo.lock()->id);
drawP.world.con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_ERASE_SINGLE_COMPONENT, id);
}
void DrawComponent::client_send_erase_set(DrawingProgram& drawP, const std::unordered_set<ServerClientID>& ids) {

View file

@ -63,15 +63,16 @@ class DrawComponent {
void canvas_do_calculated_transform(SkCanvas* canvas);
void calculate_draw_transform(const DrawData& drawData);
void server_send_place(MainServer& server, ServerClientID id, uint64_t placement);
void server_send_place(MainServer& server, uint64_t placement);
static void server_send_place_many(MainServer& server, std::vector<CollabListType::ObjectInfoPtr>& comps);
static void server_send_erase(MainServer& server, ServerClientID id);
static void server_send_erase_set(MainServer& server, const std::unordered_set<ServerClientID>& ids);
void server_send_update(MainServer& server, ServerClientID id);
void server_send_update(MainServer& server);
static void server_send_transform_many(MainServer& server, const std::vector<std::pair<ServerClientID, CoordSpaceHelper>>& transforms);
std::weak_ptr<CollabListType::ObjectInfo> collabListInfo;
std::weak_ptr<DrawingProgramCacheBVHNode> parentBvhNode;
ServerClientID id;
#ifndef IS_SERVER
std::chrono::time_point<std::chrono::steady_clock> lastUpdateTime;