Skip to content

Commit

Permalink
updated: instance&type extraction on steam3 conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
rejchev committed Oct 29, 2024
1 parent c0385e0 commit 119f8f7
Showing 1 changed file with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import ru.rejchev.steamid.SteamID;
import ru.rejchev.steamid.SteamIDAccountType;
import ru.rejchev.steamid.SteamIDMaskType;
import ru.rejchev.steamid.SteamIDUniverse;
import ru.rejchev.steamid.converters.base.AStringSteamIDConverter;

import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringSteam3Converter extends AStringSteamIDConverter {
Expand Down Expand Up @@ -39,15 +38,35 @@ public SteamID convert(Object value) {
if((steamID = super.convert(value)) == null)
return null;

// TODO: ...
try { steamID
// TODO: testing
try {

String buff;
if((buff = getMatcher().group(RequiredBinds[0])) == null || buff.length() != 1)
return null;

char type = buff.charAt(0);

long instance = (type != 'g' && type != 'T' && type != 'c' && type != 'L') ? 0 : 1;

if((buff = getMatcher().group(OptionalBinds[0])) != null && !buff.isEmpty())
instance = Long.parseLong(buff);

if(type == 'c') {
instance |= ((SteamIDMaskType.AccountInstance.getMask() + 1) >> 1);
type = SteamIDAccountType.Chat.getChar();
}

if(type == 'L') {
instance |= ((SteamIDMaskType.AccountInstance.getMask() + 1) >> 2);
type = SteamIDAccountType.Chat.getChar();
}

steamID
.setAccountId((Long.parseUnsignedLong(getMatcher().group(RequiredBinds[2]))))
.setInstance(1)
.setInstance(instance)
.setAccountUniverse(SteamIDUniverse.values()[Integer.parseUnsignedInt(getMatcher().group(RequiredBinds[1]))])
.setAccountType(SteamIDAccountType.of(Integer.parseUnsignedInt(getMatcher().group(OptionalBinds[0]))));

if(getMatcher().group(OptionalBinds[1]) != null)
steamID.setInstance(Long.parseUnsignedLong(getMatcher().group(OptionalBinds[0])));
.setAccountType((type == SteamIDAccountType.InvalidCharacter) ? SteamIDAccountType.Invalid : SteamIDAccountType.of(type));
}
catch (NumberFormatException e) { return null; }

Expand Down

0 comments on commit 119f8f7

Please sign in to comment.