Skip to content

IGamePlayer::GetName with multibyte characters #1315

@shqke

Description

@shqke

Following https://forums.alliedmods.net/showthread.php?t=305561
Game: Left 4 Dead 2

   0xe9519b50 <+0>:     push   %ebp
   0xe9519b51 <+1>:     mov    %esp,%ebp
   0xe9519b53 <+3>:     sub    $0x8,%esp
   0xe9519b56 <+6>:     mov    0x8(%ebp),%ecx
   0xe9519b59 <+9>:     mov    0x38(%ecx),%eax
   0xe9519b5c <+12>:    test   %eax,%eax
   0xe9519b5e <+14>:    je     0xe9519b72 <_ZN7CPlayer7GetNameEv+34>	// if (m_Info && ...
   0xe9519b60 <+16>:    mov    0x34(%ecx),%edx
   0xe9519b63 <+19>:    cmpl   $0x0,0xc(%edx)
   0xe9519b67 <+23>:    je     0xe9519b72 <_ZN7CPlayer7GetNameEv+34>
   0xe9519b69 <+25>:    mov    (%eax),%ecx				// ... m_pEdict->GetUnknown())
   0xe9519b6b <+27>:    mov    %eax,(%esp)
   0xe9519b6e <+30>:    call   *(%ecx)
   0xe9519b70 <+32>:    jmp    0xe9519b7f <_ZN7CPlayer7GetNameEv+47>	// return m_Info->GetName();
   0xe9519b72 <+34>:    mov    0x8(%ecx),%ecx
   0xe9519b75 <+37>:    test   %ecx,%ecx
   0xe9519b77 <+39>:    mov    $0xe95af817,%eax
=> 0xe9519b7c <+44>:    cmovne %ecx,%eax				// return m_Name.c_str();
   0xe9519b7f <+47>:    add    $0x8,%esp
   0xe9519b82 <+50>:    pop    %ebp
   0xe9519b83 <+51>:    ret
End of assembler dump.

^ Marked instruction only gets executed during initial connect, then #545 appears to be useless.

Could you tell why not return m_Name here?
Could I make a PR to return m_Name or should I change IGamePlayer interface's method into const char *GetName(fixed = true) (following change for sp include) with corresponding return values?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggeneral bugs; can be anything

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions