From 3b4b4afe572557e1543d5e20cdd768b5b15c84f2 Mon Sep 17 00:00:00 2001 From: craziness924 Date: Fri, 17 Dec 2021 12:32:13 -0600 Subject: [PATCH 1/3] Attempt at fixing Demos --- carball/json_parser/actor/car.py | 7 ++++--- carball/json_parser/frame_parser.py | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/carball/json_parser/actor/car.py b/carball/json_parser/actor/car.py index d0cb2e74..b630a23d 100644 --- a/carball/json_parser/actor/car.py +++ b/carball/json_parser/actor/car.py @@ -48,10 +48,11 @@ def update(self, actor: dict, frame_number: int, time: float, delta: float) -> N } def add_demo(self, actor, frame_number): - if 'TAGame.Car_TA:ReplicatedDemolish' in actor: - demo_data = actor['TAGame.Car_TA:ReplicatedDemolish'] + if 'TAGame.Car_TA:ReplicatedDemolishGoalExplosion' in actor: + demo_data = actor['TAGame.Car_TA:ReplicatedDemolishGoalExplosion'] # add attacker and victim player ids attacker_car_id = demo_data['attacker'] + victim_car_id = demo_data['victim'] if attacker_car_id != -1 and victim_car_id != -1 and attacker_car_id < 1e9 and victim_car_id < 1e9: # Filter out weird stuff where it's not a demo @@ -69,4 +70,4 @@ def add_demo(self, actor, frame_number): logger.debug('RepDemo Names: Att: %s. Def: %s' % (self.parser.player_dicts[attacker_player_id]['name'], self.parser.player_dicts[victim_player_id]['name'])) - actor.pop('TAGame.Car_TA:ReplicatedDemolish') + actor.pop('TAGame.Car_TA:ReplicatedDemolishGoalExplosion') diff --git a/carball/json_parser/frame_parser.py b/carball/json_parser/frame_parser.py index eeab6bc0..a145c9be 100644 --- a/carball/json_parser/frame_parser.py +++ b/carball/json_parser/frame_parser.py @@ -1,4 +1,5 @@ from .actor import * +import json REPLICATED_RB_STATE_KEY = 'TAGame.RBActor_TA:ReplicatedRBState' @@ -153,6 +154,7 @@ def parse_frames(self): for new_actor in frame['new_actors']: actor_id = new_actor['actor_id'] object_name = self.objects[new_actor['object_id']] + self.actors[actor_id] = { 'Id': actor_id, 'TypeName': object_name, @@ -207,6 +209,9 @@ def parse_frames(self): # skip 0 delta frames, except for these two handlers (matches old implementation) if handler_tuple[1] or delta != 0: handler.update(self.actors[actor_id], i, time, delta) + # if(handler.type_name == CarHandler.type_name): -cr, logs everytime a car attribute is used + # with open("walter.json", "a") as f: + # f.write(json.dumps(self.actors[actor_id])) self.current_car_ids_to_collect.clear() From f343d75c4547a66f54de4069f3347734d5cb687d Mon Sep 17 00:00:00 2001 From: craziness924 Date: Wed, 27 Apr 2022 23:32:23 -0500 Subject: [PATCH 2/3] Adds support for older Demo Component --- carball/json_parser/actor/car.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/carball/json_parser/actor/car.py b/carball/json_parser/actor/car.py index b630a23d..706900ca 100644 --- a/carball/json_parser/actor/car.py +++ b/carball/json_parser/actor/car.py @@ -71,3 +71,26 @@ def add_demo(self, actor, frame_number): (self.parser.player_dicts[attacker_player_id]['name'], self.parser.player_dicts[victim_player_id]['name'])) actor.pop('TAGame.Car_TA:ReplicatedDemolishGoalExplosion') + elif 'TAGame.Car_TA:ReplicatedDemolish' in actor: + demo_data = actor['TAGame.Car_TA:ReplicatedDemolish'] + # add attacker and victim player ids + attacker_car_id = demo_data['attacker'] + + victim_car_id = demo_data['victim'] + if attacker_car_id != -1 and victim_car_id != -1 and attacker_car_id < 1e9 and victim_car_id < 1e9: + # Filter out weird stuff where it's not a demo + # frame 1 of 0732D41D4AF83D610AE2A988ACBC977A (rlcs season 4 eu) + attacker_player_id = self.parser.car_player_ids[attacker_car_id] + victim_player_id = self.parser.car_player_ids[victim_car_id] + if attacker_player_id != -1 and victim_player_id != -1: + demo_data['attacker_player_id'] = attacker_player_id + demo_data['victim_player_id'] = victim_player_id + # add frame_number + demo_data['frame_number'] = frame_number + self.parser.demos_data.append(demo_data) + logger.debug('ReplicatedDemolish: Att: %s, Def: %s' % + (attacker_player_id, victim_player_id)) + logger.debug('RepDemo Names: Att: %s. Def: %s' % + (self.parser.player_dicts[attacker_player_id]['name'], + self.parser.player_dicts[victim_player_id]['name'])) + actor.pop('TAGame.Car_TA:ReplicatedDemolish') From b6a63eedfaa2596ebc277c47b8e786c4eeec45ad Mon Sep 17 00:00:00 2001 From: craziness924 Date: Thu, 28 Apr 2022 11:23:53 -0500 Subject: [PATCH 3/3] Removes debug code --- carball/json_parser/frame_parser.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/carball/json_parser/frame_parser.py b/carball/json_parser/frame_parser.py index a145c9be..82563f89 100644 --- a/carball/json_parser/frame_parser.py +++ b/carball/json_parser/frame_parser.py @@ -1,5 +1,4 @@ from .actor import * -import json REPLICATED_RB_STATE_KEY = 'TAGame.RBActor_TA:ReplicatedRBState' @@ -209,9 +208,6 @@ def parse_frames(self): # skip 0 delta frames, except for these two handlers (matches old implementation) if handler_tuple[1] or delta != 0: handler.update(self.actors[actor_id], i, time, delta) - # if(handler.type_name == CarHandler.type_name): -cr, logs everytime a car attribute is used - # with open("walter.json", "a") as f: - # f.write(json.dumps(self.actors[actor_id])) self.current_car_ids_to_collect.clear()