From 04c66b0c9cbe036efc425a60b1dbfa6e688e9a23 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Fri, 28 Oct 2011 22:49:02 +0300 Subject: [PATCH] Attempt to persist attached objects in storage and clipboard, part 1: Store child objects in the same line as their parent object. Objects are separated by the ; symbol. --- qcsrc/server/mutators/sandbox.qc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 2495fdb98..a776613ef 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -150,12 +150,10 @@ void sandbox_ObjectRemove(entity e) object_count -= 1; } -string sandbox_ObjectPort_Save(entity e, float database) +string sandbox_ObjectPort_Save_string(entity e, float database) { - // save object properties string s; - - s = strcat(e.model, " "); + s = strcat(s, e.model, " "); s = strcat(s, ftos(e.skin), " "); s = strcat(s, ftos(e.alpha), " "); s = strcat(s, sprintf("\"%.9v\"", e.colormod), " "); @@ -171,6 +169,22 @@ string sandbox_ObjectPort_Save(entity e, float database) s = strcat(s, sprintf("\"%.9v\"", e.origin), " "); s = strcat(s, sprintf("\"%.9v\"", e.angles), " "); } + s = strcat(s, "; "); + return s; +} +string sandbox_ObjectPort_Save(entity e, float database) +{ + // save object properties + string s; + entity head; + + // first set the properties of the main object, then those of each child + s = sandbox_ObjectPort_Save_string(e, database); + for(head = world; (head = find(head, classname, "object")); ) + { + if(head.owner == e) + s = strcat(s, sandbox_ObjectPort_Save_string(head, database)); + } return s; } -- 2.39.2