AttorneyOnline / tsuserver3

An Attorney Online server.
GNU Affero General Public License v3.0
25 stars 51 forks source link

Update all char.inis to vanilla-2021.04 #180

Closed in1tiate closed 3 years ago

in1tiate commented 3 years ago

Should fix issues with users not being able to use certain emotes due to iniswap detection.

caleb-mabry commented 3 years ago

Should I getting these messages on startup?

characters\April\char.ini does not have the required sections
characters\Butz\char.ini does not have the required sections
characters\Diego\char.ini does not have the required sections
characters\Edgeworthw\char.ini does not have the required sections
characters\Ema\char.ini does not have the required sections
characters\Franny\char.ini does not have the required sections
characters\Gavin K\char.ini does not have the required sections
characters\Gumshoe\char.ini does not have the required sections
characters\Gumshoey\char.ini does not have the required sections
characters\Ini\char.ini does not have the required sections
characters\Klav\char.ini does not have the required sections
characters\Lana\char.ini does not have the required sections
characters\Maggey\char.ini does not have the required sections
characters\Matt\char.ini does not have the required sections
characters\Maya\char.ini does not have the required sections
characters\Pearl\char.ini does not have the required sections
characters\Phoenix\char.ini does not have the required sections
characters\Valant\char.ini does not have the required sections
characters\Zak\char.ini does not have the required sections
Character file characters\zettaslow\char.ini not found
in1tiate commented 3 years ago

Ugh, it's because for some ungodly reason tsuserver3 wants [SoundN] to exist. I'll patch that out, give me a few minutes.

in1tiate commented 3 years ago

Actually, [SoundN] is pretty deeply entrenched into the char.ini parser. I'll just add an empty [SoundN] section to the inis without it.

caleb-mabry commented 3 years ago

This actually has the potential to break things.

    def _create_emotes(self, emote_ids: List[str], char_ini: ConfigParser):
        for emote_id in emote_ids:
            emotion_information = char_ini['Emotions'].get(emote_id)
            if emotion_information is not None:
                _name, preanim, anim, _mod = emotion_information.split('#')[
                    :4]
                sfx = self._get_sfx(emote_id, char_ini)
                print(type(sfx))
                self.emotes.add((preanim, anim, sfx))

                # No SFX should always be allowed
                self.emotes.add((preanim, anim, None))

    @staticmethod
    def _get_sfx(emote_id: str, char_ini: ConfigParser) -> Union[str, None]:
        if emote_id in char_ini['SoundN']:
            sfx = char_ini['SoundN'][emote_id]
            if len(sfx) == 1:
                # Often, a one-character SFX is a placeholder for no sfx,
                # so allow it
                sfx = None
        else:
            sfx = None

With sfx having the ability to be None, we can run into problems with the validation method.

    def validate(self, preanim: str, anim: str, sfx: Union[str, None]) -> bool:
        """
        Determines whether or not an emote canonically belongs to this
        character (that is, it is defined server-side).
        """
        # There are no emotes loaded, so allow anything
        if len(self.emotes) == 0:
            return True

        if len(sfx) <= 1:
            sfx = None
        return (preanim, anim, sfx) in self.emotes

Since sfx could either be None or str this raises a type error the len(sfx) portion of validation. TypeError being NoneType has no len()

Thoughts on ways we can prevent this error from happening?

oldmud0 commented 3 years ago

revert https://github.com/AttorneyOnline/tsuserver3/pull/180/commits/f425fbf4491e9cc6a8c09e32618efd918253fc5c and we can fix it up in code

@caleb-mabry

        if sfx is not None and len(sfx) <= 1:
            sfx = None
oldmud0 commented 3 years ago

I think we should enforce FrameSFX as well but that can go in a separate PR