diff --git a/.gitignore b/.gitignore index 3e9461e..7810ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ +# Artifacts *.pyc +build/ +dist/ +astron.egg-info/ +# Misc +.idea/ .project .pydevproject -.gitignore *.log* *.db diff --git a/astron/distributed_object.py b/astron/distributed_object.py index 90f9c82..3dca5a5 100644 --- a/astron/distributed_object.py +++ b/astron/distributed_object.py @@ -63,11 +63,11 @@ def init(self): print("DO created without custom init(): %d (%s)" % (self.do_id, str(type(self)))) def delete(self): - """Overwrite this to execute code just before a views deletion.""" + """Overwrite this to execute code just before a views' deletion.""" # FIXME: Redup in object_repository if the docstring is actually accurate. print("DO deleted: %d" % (self.do_id, )) - def update_field(self, sender, field_id, dgi): + def update_field(self, field_id, dgi, sender=None): """Handles incoming SET_FIELD updates.""" decoded_args = [] field = self.dclass.get_field(self.field_id_to_dmethod_id[field_id]) @@ -80,7 +80,10 @@ def update_field(self, sender, field_id, dgi): else: decoded_args.append(self.type_unpacker[arg_type](dgi)) # print("Updating field %s in %d with args %s" % (field.name(), self.do_id, str(decoded_args))) - getattr(self, field.name())(sender, *decoded_args) + if sender: + getattr(self, field.name())(sender, *decoded_args) + return + getattr(self, field.name())(*decoded_args) # update field on client (CA doesn't send sender) def send_update(self, field_name, *values): """Handles outgoing SET_FIELD updates.""" diff --git a/astron/object_repository.py b/astron/object_repository.py index 8ce44de..cdcc0ac 100644 --- a/astron/object_repository.py +++ b/astron/object_repository.py @@ -210,6 +210,7 @@ def __init__(self, dcfilename=default_dcfilename, stateserver = 400000, dbss = 4 self.msg_type = MSG_TYPE_INTERNAL self.handlers.update({ servermsg.STATESERVER_OBJECT_SET_FIELD : self.handle_STATESERVER_OBJECT_SET_FIELD, + servermsg.STATESERVER_OBJECT_DELETE_RAM : self.handle_STATESERVER_OBJECT_DELETE_RAM, servermsg.STATESERVER_OBJECT_CHANGING_LOCATION : self.handle_STATESERVER_OBJECT_CHANGING_LOCATION, servermsg.STATESERVER_OBJECT_GET_AI : self.handle_STATESERVER_OBJECT_GET_AI, servermsg.STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED: self.handle_STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED, @@ -379,7 +380,12 @@ def send_STATESERVER_OBJECT_GET_ZONE_OBJECTS(self, context, parent_id, zone_id): def handle_STATESERVER_OBJECT_SET_FIELD(self, dgi, sender, recipients): do_id = dgi.read_uint32() field_id = dgi.read_uint16() - self.distributed_objects[do_id].update_field(sender, field_id, dgi) + self.distributed_objects[do_id].update_field(field_id, dgi, sender=sender) + + def handle_STATESERVER_OBJECT_DELETE_RAM(self, dgi, sender, recipients): + do_id = dgi.read_uint32() + dist_obj = self.distributed_objects[do_id] + dist_obj.delete() def handle_STATESERVER_OBJECT_CHANGING_LOCATION(self, dgi, sender, recipients): print("handle_STATESERVER_OBJECT_CHANGING_LOCATION", sender, recipients) @@ -627,8 +633,8 @@ def handle_CLIENT_DONE_INTEREST_RESP(self, dgi): def handle_CLIENT_OBJECT_SET_FIELD(self, dgi): do_id = dgi.read_uint32() field_id = dgi.read_uint16() - # FIXME: There's still the value in the dgi - # FIXME: Implement + dist_obj = self.distributed_objects[do_id] + dist_obj.update_field(field_id, dgi) def handle_CLIENT_OBJECT_SET_FIELDS(self, dgi): do_id = dgi.read_uint32()