In our support boards we aim to provide support for the B3 core in its current state. Older releases of B3 are NOT supported. Check our front page for the latest version. You may post feature requests in our General Discussion board. Modifications and Hacks of the core B3 code are NOT supported.
Before you ask for support: [ Read the Support Instructions ] - More info: [ Full Support Disclaimer ]

Pages: [1] 2   Go Down
  Print  
Author Topic: COD4 Parser Issue  (Read 585 times) Bookmark and Share
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« on: January 16, 2012, 07:33:28 PM »

Hey there, having a slight parsing issue with one of our servers. The server runs a MW2 Ftag mod and the kills are outputted to the log file differently. Could someone point me in the right direction on how to get this working, i know iv'e read somewhere that you can change the parser information but not sure where to start. The current install is on windows.

This is from another server and works fine:

K;5927f7208efd369124dbdb574acbf07f;10;;RatCamper;56fc39ed327dcaf5f01088e450cc7a94;1;;excalibure02;dragunov_mp;360;MOD_RIFLE_BULLET;torso_lower

This is from the modded server:

K;;2;axis;Wildthing>XI<AD;;21;allies;VicPolaris>XI<;g3_silencer_mp;67;MOD_RIFLE_BULLET;right_leg_upper

As you can see the guid has been removed from the message and the team has been added in. Theoretically its all still possible to make it work just not 100% sure how..

Thanks, Duc.
Logged

Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #1 on: January 16, 2012, 09:06:47 PM »

You would need to change the kills/damage regular expression in the cod.py parser, so you would probably want to make a parser with a new name to keep it separate.
Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #2 on: January 16, 2012, 10:21:41 PM »

OK.. so what i'v done is download the PyPi package and create a custom parser called codcust.py, then I have pasted the content of the cod4 one into that then I have placed the following code for the parsing:

Code:
        # player kills/damage
        #re.compile(r'^(?P<action>[A-Z]);(?P<data>(?P<guid>[^;]+);(?P<cid>[0-9]{1,2});(?P<team>[a-z]*);(?P<name>[^;]+);(?P<aguid>[^;]+);(?P<acid>[0-9]{1,2});(?P<ateam>[a-z]*);(?P<aname>[^;]+);(?P<aweap>[a-z0-9_-]+);(?P<damage>[0-9.]+);(?P<dtype>[A-Z_]+);(?P<dlocation>[a-z_]+))$', re.IGNORECASE),
        re.compile(r'^(?P<action>[A-Z])(?P<data>;;(?P<cid>[0-9-]{1,2});(?P<team>[a-z]+);(?P<name>[^;]+);;(?P<acid>[0-9-]{1,2});(?P<ateam>[a-z]+);(?P<aname>[^;]*);(?P<aweap>[a-z0-9_-]+);(?P<damage>[0-9.]+);(?P<dtype>[A-Z_]+);(?P<dlocation>[a-z_]+))$', re.IGNORECASE),   

Is that all that's required? I have no knowledge of how B3 will link kills to players etc.. I think the regex is right but I have never been too good at that lol.

When I want to test this do I just put codcust in the parser field?
Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #3 on: January 17, 2012, 06:12:59 AM »

OK couldn't work out how to make it load a custom parser so modified the cod parser with the new regex line and this is what I get in my log:

Code:
CONSOLE '1024:38 K;;7;allies;Princess!;;20;axis;euzen(fin)>XI<;g36c_silencer_mp;40;MOD_RIFLE_BULLET;left_foot'
120117 14:09:38 DEBUG "No victim {'dlocation': 'left_foot', 'aweap': 'g36c_silencer_mp', 'name': 'Princess!', 'cid': '7', 'dtype': 'MOD_RIFLE_BULLET', 'ateam': 'axis', 'damage': '40', 'team': 'allies', 'action': 'K', 'acid': '20', 'data': ';;7;allies;Princess!;;20;axis;euzen(fin)>XI<;g36c_silencer_mp;40;MOD_RIFLE_BULLET;left_foot', 'aname': 'euzen(fin)>XI<'}"
120117 14:09:38 ERROR 'could not parse line no such group: [(\'C:\\\\Users\\\\Administrator\\\\Desktop\\\\b3-1.7.1\\\\b3\\\\parser.py\', 898, \'run\', \'self.parseLine(line)\'), (\'C:\\\\Users\\\\Administrator\\\\Desktop\\\\b3-1.7.1\\\\b3\\\\parsers\\\\q3a\\\\abstractParser.py\', 194, \'parseLine\', \'event = func(action, data, match)\'), (\'C:\\\\Users\\\\Administrator\\\\Desktop\\\\b3-1.7.1\\\\b3\\\\parsers\\\\cod4.py\', 66, \'OnK\', \'self.OnJ(action, data, match)\'), (\'C:\\\\Users\\\\Administrator\\\\Desktop\\\\b3-1.7.1\\\\b3\\\\parsers\\\\cod.py\', 262, \'OnJ\', "codguid = match.group(\'guid\')")]'


Really need some help on this one please.

Duc.
« Last Edit: January 17, 2012, 08:49:31 AM by Sitting-Duc » Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #4 on: January 17, 2012, 06:15:58 AM »

What is the error that you get with the stock parser?
Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #5 on: January 17, 2012, 06:32:14 AM »

What is the error that you get with the stock parser?

I get this error as the mod has changed the output format for kills.

Code:
120117 03:19:23 CONSOLE '374:05 K;;23;axis;W2|Duke;;10;allies;Angel >XI<;g3_silencer_mp;67;MOD_RIFLE_BULLET;torso_upper'
120117 03:19:23 VERBOSE 'line did not match format: K;;23;axis;W2|Duke;;10;allies;Angel >XI<;g3_silencer_mp;67;MOD_RIFLE_BULLET;torso_upper'

Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #6 on: January 17, 2012, 07:38:38 AM »

Do the players ever get authenticated on the server? (See what the b3 log says).

Because your regex seems to return the correct info and has the correct cid for the victim.



To change the name of the parser you would need to change:

class Cod4Parser(b3.parsers.cod2.Cod2Parser):
    gameName = 'cod4'

to something like:

class Cod4modParser(b3.parsers.cod2.Cod2Parser):
    gameName = 'cod4mod'

as well as change the name of the file to cod4mod.py

(I think that is all you need to do anyway, not something that I've done a lot)
« Last Edit: January 17, 2012, 07:43:51 AM by 82ndAB.Bravo17 » Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #7 on: January 17, 2012, 10:00:10 AM »

Ok i see where the issue is, the mod also seems to have modified the on connect message to:

Code:
J;;21;BADDger
J;;20;euzen(fin)>XI<
J;;17;ChiefBSr>XI<

I have attempted to add the following regex but B3 will not load saying there is a syntax error which i cannot see, some help would be appreciated here.

Code:
re.compile(r'^(?P<action>[A-Z]);(?P<data>(?P<cid>[0-9]{1,2});(?P<name>[^;]+))$', re.IGNORECASE)

Duc.
Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #8 on: January 17, 2012, 10:41:06 AM »

Does the mod work with pb enabled?
Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #9 on: January 17, 2012, 11:23:04 AM »

No unfortunately there are issues when you run PB and this type of game mod, so no luck there :/

I see in the b3.log that clients are being added on events when they do not exist in the database but if this has not happened before the kill then it fails as onK calls onJ (if I have read it right).

Duc.
Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #10 on: January 17, 2012, 12:12:03 PM »

With no guids and no pb (so no ips) you will have difficulty keeping track of players, as all you have to id them is their name, which they can easily change, so I am not sure how useful B3 will be to you.
Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #11 on: January 17, 2012, 01:08:22 PM »

With no guids and no pb (so no ips) you will have difficulty keeping track of players, as all you have to id them is their name, which they can easily change, so I am not sure how useful B3 will be to you.

OK I see what your saying, this is the code that is associated with the kill event:

Code:
   def OnK(self, action, data, match=None):
        victim = self.getClient(victim=match)
        if not victim:
            self.debug('No victim')
            self.OnJ(action, data, match)
            return None

Now the 'self.OnJ(action, data, match)' is obviously unusable as it doesn't contain the correct data. Is what im attempting to do here possible:

Code:
   def OnK(self, action, data, match=None):
        victim = self.clients.getByCID(match.group('cid'))
        if not victim:
            #Force status update here
            victim = self.clients.getByCID(match.group('cid'))
        
        if not victim: #Failed to get player object a second time so give up
            self.debug('No victim %s' % match.groupdict())
            return None

is this possible and if so would someone mind helping me out with it?  Basically im attempting to get the player via cid however if they have not performed a previous action then this will fail so i need to perform a 'status' update.

Duc.
« Last Edit: January 17, 2012, 01:25:52 PM by Sitting-Duc » Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #12 on: January 17, 2012, 04:41:57 PM »

The regex should be

Code:
re.compile(r'^(?P<action>[A-Z]);;(?P<data>(?P<cid>[0-9]{1,2});(?P<name>[^;]+))$', re.IGNORECASE

you need the extra ; in there for the empty guid space.

I'm not sure why you were getting a syntax error, must be something else that was done.

Which mod is it, it might be better to get the mod to output a guid rather than try to get B3 to work without one.

What does a log from the mod actually look like, and what currently gets filled in in the b3 clients table once someone gets authenticated.

Code:
victim = self.clients.getByCID(match.group('cid'))

I think that this will only get a client if they are already authenticated, and if they were we wouldn't have got to here in the first place.



Logged
Dev. Team
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: COD2,COD4,COD5
Posts: 1096
Offline Offline
« Reply #13 on: January 18, 2012, 07:30:37 AM »

Further thoughts:

What does a status output look like?

Is is the Mod or Freezetag that you want? Because the Openwarfare mod has a freezetag gametype and works well with B3 (at least the other gametypes do)
Logged
Jr. Member
**
OS: Windows
Type: Renting Server, no B3
Gameservers: COD2, COD4, COD5, COD BlackOps, COD MW3, BF3, Crysis Wars
Posts: 30
Offline Offline
« Reply #14 on: January 18, 2012, 08:03:35 AM »

Nearly sorted!

This is the code I used:

Code:
   # kill
    def OnK(self, action, data, match=None):
        victim = self.getClient(victim=match)
        
        if victim:
            if victim.name != match.group('name'):
                self.debug('SYNC REQUIRED!')
                mlist = self.sync(self)
                return None
        
        if not victim:
            plist = self.getPlayerList(maxRetries=2)
            for cid, c in plist.iteritems():
                client = self.clients.getByCID(cid)
                if not client:
                    if cid == match.group('cid'):
                        if self._counter.get(cid):
                            self.verbose('cid: %s already in authentication queue. Aborting Join.' %cid)
                            return None
                        self._counter[cid] = 1
                        t = threading.Timer(2, self.newPlayer, (cid, c['guid'], c['name']))
                        t.start()
                        self.debug('%s connected, waiting for Authentication...' %c['name'])
                        self.debug('Our Authentication queue: %s' % self._counter)
        if not victim:
            return None
                
        attacker = self.getClient(attacker=match)
        
        if attacker:
            if attacker.name != match.group('aname'):
                self.debug('SYNC REQUIRED!')
                mlist = self.sync(self)
                return None
        
        if not attacker:
            plist = self.getPlayerList(maxRetries=2)
            for cid, c in plist.iteritems():
                client = self.clients.getByCID(cid)
                if not client:
                    if cid == match.group('acid'):
                        if self._counter.get(cid):
                            self.verbose('acid: %s already in authentication queue. Aborting Join.' %cid)
                            return None
                        self._counter[cid] = 1
                        t = threading.Timer(2, self.newPlayer, (cid, c['guid'], c['name']))
                        t.start()
                        self.debug('%s connected, waiting for Authentication...' %c['name'])
                        self.debug('Our Authentication queue: %s' % self._counter)
        if not attacker:
            return None

        # COD4 doesn't report the team on kill, only use it if it's set
        # Hopefully the team has been set on another event
        if match.group('ateam'):
            attacker.team = self.getTeam(match.group('ateam'))

        if match.group('team'):
            victim.team = self.getTeam(match.group('team'))

        attacker.name = match.group('aname')
        victim.name = match.group('name')

        event = b3.events.EVT_CLIENT_KILL
        
        if attacker.cid == victim.cid or attacker.cid == '-1':
            self.verbose2('Suicide Detected')
            event = b3.events.EVT_CLIENT_SUICIDE
        elif attacker.team != b3.TEAM_UNKNOWN and \
             attacker.team and \
             victim.team and \
             attacker.team == victim.team:
            self.verbose2('Teamkill Detected')
            event = b3.events.EVT_CLIENT_KILL_TEAM

        victim.state = b3.STATE_DEAD
        return b3.events.Event(event, (float(match.group('damage')), match.group('aweap'), match.group('dlocation'), match.group('dtype')), attacker, victim)

Seems to work fine and the stats are being added to db. There's one issue that when a client disconnects (I think the d/c log has also been modified by the modder) where it takes a while for B3 to realise this and update. To partially get around this I added the sync call but it doesnt seem to like it...

If you have any suggestions on the code I would be very grateful as I am certainly not experienced in this language.

Thanks for all the help you have given me in this topic.

Duc.

EDIT: This is the error im getting when sync is called:
Code:
120118 16:08:28 DEBUG 'SYNC REQUIRED!'
120118 16:08:28 ERROR "could not parse line sync() takes exactly 1 argument (2 given)

EDIT: We already run 2 servers with the openwarfare mod Smiley
« Last Edit: January 18, 2012, 08:13:46 AM by Sitting-Duc » Logged
Tags:
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal