Skip to content

Commit ee05b12

Browse files
committed
fix bug in server action parser
1 parent 4c8f1c2 commit ee05b12

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Server/Server.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,17 @@ def make_world(self):
329329
def action_parse(self, msg):
330330
message = parse(msg[0])
331331
address = msg[1]
332+
if address not in self.agents:
333+
logging.error('message from invalid address, address: {}'.format(address))
334+
return False
332335
if message.type is not 'MessageClientAction':
333336
logging.error('message type is not action, client: {}'
334337
.format(self.agents.get(address, Agent()).name))
338+
if self.agents[address].last_action_cycle < self.cycle:
339+
self.agents[address].last_action_cycle = self.cycle
340+
self.receive_action += 1
335341
return False
336-
if address not in self.agents:
337-
logging.error('message from invalid address, address: {}'.format(address))
338-
return False
342+
339343
action = action_to_vector(message.string_action)
340344
self.save_rcl(self.agents[address].id, message.string_message, action)
341345
if action is None:

0 commit comments

Comments
 (0)