skadistats.clarity.processor.reader.OnMessage Java Examples

The following examples show how to use skadistats.clarity.processor.reader.OnMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Parse.java    From parser with MIT License 6 votes vote down vote up
@OnMessage(CDOTAUserMsg_LocationPing.class)
public void onPlayerPing(Context ctx, CDOTAUserMsg_LocationPing message) {
    pingCount += 1;
    if (pingCount > 10000) {
        return;
    }

    Entry entry = new Entry(time);
    entry.type = "pings";
    entry.slot = message.getPlayerId();
    /*
    System.err.println(message);
    player_id: 7
    location_ping {
      x: 5871
      y: 6508
      target: -1
      direct_ping: false
      type: 0
    }
    */
    //we could get the ping coordinates/type if we cared
    //entry.key = String.valueOf(message.getOrderType());
    output(entry);
}
 
Example #2
Source File: GameEvents.java    From clarity with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@OnMessage(NetMessages.CSVCMsg_GameEventList.class)
public void onGameEventList(NetMessages.CSVCMsg_GameEventList message) {
    for (NetMessages.CSVCMsg_GameEventList.descriptor_t d : message.getDescriptorsList()) {
        String[] keys = new String[d.getKeysCount()];
        for (int i = 0; i < d.getKeysCount(); i++) {
            NetMessages.CSVCMsg_GameEventList.key_t k = d.getKeys(i);
            keys[i] = k.getName();
        }
        GameEventDescriptor gev = new GameEventDescriptor(
            d.getEventid(),
            d.getName(),
            keys
        );
        byName.put(gev.getName(), gev);
        byId.put(gev.getEventId(), gev);
        evGameEventDescriptor.raise(gev);
    }
    if (preListBuffer != null) {
        preListBuffer.forEach(this::onGameEvent);
        preListBuffer = null;
    }
}
 
Example #3
Source File: S1StringTableEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@OnMessage(S1NetMessages.CSVCMsg_CreateStringTable.class)
public void onCreateStringTable(S1NetMessages.CSVCMsg_CreateStringTable message) {
    if (isProcessed(message.getName())) {
        StringTable table = new StringTable(
            message.getName(),
            message.getMaxEntries(),
            message.getUserDataFixedSize(),
            message.getUserDataSize(),
            message.getUserDataSizeBits(),
            message.getFlags()
        );
        decodeEntries(table, message.getStringData(), message.getNumEntries());
        table.markInitialState();
        evCreated.raise(numTables, table);
    }
    numTables++;
}
 
Example #4
Source File: S1DTClassEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(S1NetMessages.CSVCMsg_SendTable.class)
public void onSendTable(S1NetMessages.CSVCMsg_SendTable message) {

    if (message.getIsEnd()) {
        return;
    }

    LinkedList<SendProp> props = new LinkedList<SendProp>();
    SendTable st = new SendTable(
        message.getNetTableName(),
        props
    );

    for (S1NetMessages.CSVCMsg_SendTable.sendprop_t sp : message.getPropsList()) {
        props.add(
            new SendProp(
                st,
                sp.getType() == PropType.ARRAY.ordinal() ? props.peekLast() : null,
                sp.getType(),
                sp.getVarName(),
                sp.getFlags(),
                sp.getPriority(),
                sp.getDtName(),
                sp.getNumElements(),
                sp.getLowValue(),
                sp.getHighValue(),
                sp.getNumBits()
            )
        );
    }
    DTClass dtClass = new S1DTClass(message.getNetTableName(), st);
    evDtClass.raise(dtClass);
}
 
Example #5
Source File: CsGoEngineType.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnPostEmbeddedMessage(S1NetMessages.CSVCMsg_SendTable.class)
public void onPostSendTable(S1NetMessages.CSVCMsg_SendTable message, BitStream bs) {
    if (message.getIsEnd()) {
        Demo.CDemoClassInfo.Builder b = Demo.CDemoClassInfo.newBuilder();
        int n = bs.readSBitInt(16);
        for (int i = 0; i < n; i++) {
            b.addClassesBuilder()
                    .setClassId(bs.readSBitInt(16))
                    .setNetworkName(bs.readString(255))
                    .setTableName(bs.readString(255));
        }
        ctx.createEvent(OnMessage.class, Demo.CDemoClassInfo.class).raise(b.build());
    }
}
 
Example #6
Source File: TempEntities.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(S1NetMessages.CSVCMsg_TempEntities.class)
public void onTempEntities(S1NetMessages.CSVCMsg_TempEntities message) {
    if (evTempEntity.isListenedTo()) {
        BitStream stream = BitStream.createBitStream(message.getEntityData());
        S1DTClass cls = null;
        ReceiveProp[] receiveProps = null;
        int count = message.getNumEntries();
        while (count-- > 0) {
            stream.readUBitInt(1); // seems to be always 0
            if (stream.readBitFlag()) {
                cls = (S1DTClass) dtClasses.forClassId(stream.readUBitInt(dtClasses.getClassBits()) - 1);
                receiveProps = cls.getReceiveProps();
            }
            EntityState state = EntityStateFactory.forS1(receiveProps);
            fieldReader.readFields(stream, cls, state, null, false);

            int handle = engineType.emptyHandle();
            Entity te = new Entity(
                    engineType.indexForHandle(handle),
                    engineType.serialForHandle(handle),
                    handle,
                    cls);
            te.setExistent(true);
            te.setActive(true);
            te.setState(state);
            evTempEntity.raise(te);
        }
    }
}
 
Example #7
Source File: BaseStringTableEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(Demo.CDemoStringTables.class)
public void onStringTables(Demo.CDemoStringTables packet) {
    for (Demo.CDemoStringTables.table_t tt : packet.getTablesList()) {
        StringTable table = stringTables.byName.get(tt.getTableName());
        if (table == null) {
            continue;
        }
        applyFullStringTables(table, tt);
        for (int i = 0; i < table.getEntryCount(); i++) {
            raise(table, i, table.getNameByIndex(i), table.getValueByIndex(i));
        }
    }
}
 
Example #8
Source File: S1StringTableEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetMessages.CSVCMsg_UpdateStringTable.class)
public void onUpdateStringTable(NetMessages.CSVCMsg_UpdateStringTable message) {
    StringTable table = stringTables.forId(message.getTableId());
    if (table != null) {
        decodeEntries(table, message.getStringData(), message.getNumChangedEntries());
    }
}
 
Example #9
Source File: S2StringTableEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(S2NetMessages.CSVCMsg_CreateStringTable.class)
public void onCreateStringTable(S2NetMessages.CSVCMsg_CreateStringTable message) throws IOException {
    if (isProcessed(message.getName())) {
        StringTable table = new StringTable(
            message.getName(),
            null,
            message.getUserDataFixedSize(),
            message.getUserDataSize(),
            message.getUserDataSizeBits(),
            message.getFlags()
        );

        ByteString data = message.getStringData();
        if (message.getDataCompressed()) {
            byte[] dst;
            if (context.getBuildNumber() != -1 && context.getBuildNumber() <= 962) {
                dst = LZSS.unpack(data);
            } else {
                dst = Snappy.uncompress(ZeroCopy.extract(data));
            }
            data = ZeroCopy.wrap(dst);
        }
        decodeEntries(table, data, message.getNumEntries());
        table.markInitialState();
        evCreated.raise(numTables, table);
    }
    numTables++;
}
 
Example #10
Source File: S2StringTableEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetMessages.CSVCMsg_UpdateStringTable.class)
public void onUpdateStringTable(NetMessages.CSVCMsg_UpdateStringTable message) throws IOException {
    StringTable table = stringTables.forId(message.getTableId());
    if (table != null) {
        decodeEntries(table, message.getStringData(), message.getNumChangedEntries());
    }
}
 
Example #11
Source File: Resources.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetworkBaseTypes.CNETMsg_SpawnGroup_Load.class)
public void onLoad(NetworkBaseTypes.CNETMsg_SpawnGroup_Load message) throws IOException {
    if (spawnGroupManifests.containsKey(message.getSpawngrouphandle())) {
        throw new ClarityException("CNETMsg_SpawnGroup_Load for an already existing handle: %d", message.getSpawngrouphandle());
    }
    SpawnGroupManifest m = new SpawnGroupManifest();
    m.spawnGroupHandle = message.getSpawngrouphandle();
    m.creationSequence = message.getCreationsequence();
    m.incomplete = message.getManifestincomplete();
    spawnGroupManifests.put(m.spawnGroupHandle, m);

    addManifestData(m, message.getSpawngroupmanifest());
}
 
Example #12
Source File: Resources.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetworkBaseTypes.CNETMsg_SpawnGroup_ManifestUpdate.class)
public void onManifestUpdate(NetworkBaseTypes.CNETMsg_SpawnGroup_ManifestUpdate message) throws IOException {
    SpawnGroupManifest m = spawnGroupManifests.get(message.getSpawngrouphandle());
    if (m == null) {
        throw new ClarityException("CNETMsg_SpawnGroup_ManifestUpdate for an unknown handle: %d", message.getSpawngrouphandle());
    }

    m.incomplete = message.getManifestincomplete();
    addManifestData(m, message.getSpawngroupmanifest());
}
 
Example #13
Source File: LiveSourceTest.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test(enabled = false)
@Parameters({"srcFile", "dstFile"})
public void demoLiveSource(final String srcFile, final String dstFile) throws Exception {
    createWriterThread(srcFile, dstFile);

    LiveSource source = new LiveSource(dstFile, 5, TimeUnit.SECONDS);
    new SimpleRunner(source).runWith(new Object() {
        @OnMessage
        public void onMessage(GeneratedMessage msg) {
            System.out.println(msg.getClass().getSimpleName());
        }
    });
}
 
Example #14
Source File: S1DTClassEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(Demo.CDemoClassInfo.class)
public void onClassInfo(Demo.CDemoClassInfo message) {
    for (Demo.CDemoClassInfo.class_t ct : message.getClassesList()) {
        DTClass dt = dtClasses.forDtName(ct.getTableName());
        if (dt == null) {
            throw new ClarityException("DTClass for '%s' not found.", ct.getTableName());
        }
        dt.setClassId(ct.getClassId());
        dtClasses.byClassId.put(ct.getClassId(), dt);
    }
    dtClasses.classBits = Util.calcBitsNeededFor(dtClasses.byClassId.size() - 1);
}
 
Example #15
Source File: S2DTClassEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(Demo.CDemoSendTables.class)
public void onSendTables(Demo.CDemoSendTables sendTables) throws IOException {
    CodedInputStream cis = CodedInputStream.newInstance(ZeroCopy.extract(sendTables.getData()));
    S2NetMessages.CSVCMsg_FlattenedSerializer protoMessage = Packet.parse(
            S2NetMessages.CSVCMsg_FlattenedSerializer.class,
            ZeroCopy.wrap(cis.readRawBytes(cis.readRawVarint32()))
    );
    onFlattenedSerializers(protoMessage);
}
 
Example #16
Source File: S2DTClassEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(Demo.CDemoClassInfo.class)
public void onDemoClassInfo(Demo.CDemoClassInfo message) {
    for (Demo.CDemoClassInfo.class_t ct : message.getClassesList()) {
        DTClass dt = dtClasses.forDtName(ct.getNetworkName());
        dt.setClassId(ct.getClassId());
        dtClasses.byClassId.put(ct.getClassId(), dt);
    }
    dtClasses.classBits = Util.calcBitsNeededFor(dtClasses.byClassId.size() - 1);
    evClassesComplete.raise();
}
 
Example #17
Source File: S2DTClassEmitter.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetMessages.CSVCMsg_ClassInfo.class)
public void onServerClassInfo(NetMessages.CSVCMsg_ClassInfo message) {
    for (NetMessages.CSVCMsg_ClassInfo.class_t ct : message.getClassesList()) {
        DTClass dt = dtClasses.forDtName(ct.getClassName());
        dt.setClassId(ct.getClassId());
        dtClasses.byClassId.put(ct.getClassId(), dt);
    }
    dtClasses.classBits = Util.calcBitsNeededFor(dtClasses.byClassId.size() - 1);
    evClassesComplete.raise();
}
 
Example #18
Source File: CombatLog.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(DotaUserMessages.CDOTAUserMsg_CombatLogBulkData.class)
public void onCombatLogBulkData(DotaUserMessages.CDOTAUserMsg_CombatLogBulkData message) {
    if (logBulkData) {
        log.warn("This replay contains a CDOTAUserMsg_CombatLogBulkData message. I need one of those replays to analyze. Please report the match id: https://github.com/skadistats/clarity/issues/58");
        logBulkData = false;
    }
}
 
Example #19
Source File: CombatLog.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(DotaUserMessages.CMsgDOTACombatLogEntry.class)
public void onCombatLogEntry(DotaUserMessages.CMsgDOTACombatLogEntry message) {
    logEntries.add(new S2CombatLogEntry(
        stringTables.forName(STRING_TABLE_NAME),
        message
    ));
}
 
Example #20
Source File: LiveSource.java    From clarity with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(Demo.CDemoStop.class)
public void onDemoStop(Demo.CDemoStop msg) {
    lock.lock();
    try {
        demoStopSeen = true;
        fileChanged.signalAll();
    } finally {
        lock.unlock();
    }
}
 
Example #21
Source File: Main.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(Demo.CDemoSendTables.class)
public void onSendTables(Context ctx, Demo.CDemoSendTables message) throws IOException {
    CodedInputStream cis = CodedInputStream.newInstance(ZeroCopy.extract(message.getData()));
    int size = cis.readRawVarint32();
    S2NetMessages.CSVCMsg_FlattenedSerializer fs = Packet.parse(S2NetMessages.CSVCMsg_FlattenedSerializer.class, ZeroCopy.wrap(cis.readRawBytes(size)));

    Set<String> baseTypes = new TreeSet<>();
    for (S2NetMessages.ProtoFlattenedSerializer_t s : fs.getSerializersList()) {
        for (int fi : s.getFieldsIndexList()) {
            S2NetMessages.ProtoFlattenedSerializerField_t f = fs.getFields(fi);
            FieldType ft = new FieldType(fs.getSymbols(f.getVarTypeSym()));
            if (!f.hasFieldSerializerNameSym()) {
                int l = 0;
                do {
                    baseTypes.add(ft.getBaseType().toUpperCase());
                    if ("CUTLVECTOR".equals(ft.getBaseType().toUpperCase())) {
                        ft = ft.getGenericType();
                    } else {
                        ft = null;
                    }
                    l++;
                } while (l <= 1 && ft != null);
            }
        }
    }
    dump(ctx, fs);
}
 
Example #22
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
@OnMessage(CDemoFileInfo.class)
public void onFileInfo(Context ctx, CDemoFileInfo message) {
    //beware of 4.2b limit!  we don't currently do anything with this, so we might be able to just remove this
    //we can't use the value field since it takes Integers
    //Entry matchIdEntry = new Entry();
    //matchIdEntry.type = "match_id";
    //matchIdEntry.value = message.getGameInfo().getDota().getMatchId();
    //output(matchIdEntry);
    
    // Extracted cosmetics data from CDOTAWearableItem entities
	Entry cosmeticsEntry = new Entry();
	cosmeticsEntry.type = "cosmetics";
	cosmeticsEntry.key = new Gson().toJson(cosmeticsMap);
	output(cosmeticsEntry);

    // Dota plus hero levels
    Entry dotaPlusEntry = new Entry();
    dotaPlusEntry.type = "dotaplus";
    dotaPlusEntry.key = new Gson().toJson(dotaplusxpMap);
    output(dotaPlusEntry);

    //emit epilogue event to mark finish
    Entry epilogueEntry = new Entry();
    epilogueEntry.type = "epilogue";
    epilogueEntry.key = new Gson().toJson(message);
    output(epilogueEntry);
}
 
Example #23
Source File: Main.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetworkBaseTypes.CNETMsg_SpawnGroup_Load.class)
public void onLoad(NetworkBaseTypes.CNETMsg_SpawnGroup_Load message) throws IOException {
    System.out.println("LOAD ----------------------------------------------------------------------------------------------");
    System.out.println(message);
    parse(message.getSpawngroupmanifest());
    loaded.add(message.getSpawngrouphandle());
    if (!message.getManifestincomplete()) {
        complete.add(message.getSpawngrouphandle());
    }
}
 
Example #24
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
@OnMessage(CUserMessageSayText2.class)
public void onAllChatS2(Context ctx, CUserMessageSayText2 message) {
    Entry entry = new Entry(time);
    entry.unit = String.valueOf(message.getParam1());
    entry.key = String.valueOf(message.getParam2());
    Entity e = ctx.getProcessor(Entities.class).getByIndex(message.getEntityindex());
    entry.slot = getEntityProperty(e, "m_iPlayerID", null);
    entry.type = "chat";
    output(entry);
}
 
Example #25
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
@OnMessage(CUserMsg_SayText2.class)
public void onAllChatS1(Context ctx, CUserMsg_SayText2 message) {
    Entry entry = new Entry(time);
    entry.unit =  String.valueOf(message.getPrefix());
    entry.key =  String.valueOf(message.getText());
    entry.type = "chat";
    output(entry);
}
 
Example #26
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
@OnMessage(CDOTAUserMsg_ChatWheel.class)
public void onChatWheel(Context ctx, CDOTAUserMsg_ChatWheel message) {
	Entry entry = new Entry(time);
	entry.type = "chatwheel";
	entry.slot = message.getPlayerId();
	entry.key = String.valueOf(message.getChatMessageId());
	output(entry);
}
 
Example #27
Source File: Main.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(NetworkBaseTypes.CNETMsg_SpawnGroup_ManifestUpdate.class)
public void onManifestUpdate(NetworkBaseTypes.CNETMsg_SpawnGroup_ManifestUpdate message) throws IOException {
    System.out.println("MANIFEST UPDATE ----------------------------------------------------------------------------------------------");
    System.out.println(message);
    parse(message.getSpawngroupmanifest());
    if (!message.getManifestincomplete()) {
        complete.add(message.getSpawngrouphandle());
    }
}
 
Example #28
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
@OnMessage(CDOTAUserMsg_ChatEvent.class)
public void onChatEvent(Context ctx, CDOTAUserMsg_ChatEvent message) {
    Integer player1 = message.getPlayerid1();
    Integer player2 = message.getPlayerid2();
    Integer value = message.getValue();
    String type = String.valueOf(message.getType());
    Entry entry = new Entry(time);
    entry.type = type;
    entry.player1 = player1;
    entry.player2 = player2;
    entry.value = value;
    output(entry);
}
 
Example #29
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
@OnMessage(CDOTAUserMsg_SpectatorPlayerUnitOrders.class)
public void onSpectatorPlayerUnitOrders(Context ctx, CDOTAUserMsg_SpectatorPlayerUnitOrders message) {
    Entry entry = new Entry(time);
    entry.type = "actions";
    //the entindex points to a CDOTAPlayer.  This is probably the player that gave the order.
    Entity e = ctx.getProcessor(Entities.class).getByIndex(message.getEntindex());
    entry.slot = getEntityProperty(e, "m_iPlayerID", null);
    //Integer handle = (Integer)getEntityProperty(e, "m_hAssignedHero", null);
    //Entity h = ctx.getProcessor(Entities.class).getByHandle(handle);
    //System.err.println(h.getDtClass().getDtName());
    //break actions into types?
    entry.key = String.valueOf(message.getOrderType());
    //System.err.println(message);
    output(entry);
}
 
Example #30
Source File: Main.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnMessage(GeneratedMessage.class)
public void onMessage(GeneratedMessage message) {
    if (message instanceof S1NetMessages.CSVCMsg_VoiceData || message instanceof S2NetMessages.CSVCMsg_VoiceData) {
        return;
    }
    log.info(message.getClass().getName());
    log.info(message.toString());
}