Levak / warfacebot

WarfaceBot, a headless XMPP client for Warface (FPS game)
GNU Affero General Public License v3.0
94 stars 73 forks source link

Russian text in wb.exe #251

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi levak, add to file "wb.c" line "setlocale(0,"");" After "int main(DTP, char *argv[])".

You should get:

/**
 * WarfaceBot, a blind XMPP client for Warface (FPS)
 * Copyright (C) 2015-2017 Levak Borok <levak92@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include <wb_log.h>
#include <wb_cvar.h>
#include <wb_option.h>
#include <wb_stream.h>
#include <wb_xmpp.h>
#include <wb_xmpp_wf.h>
#include <wb_session.h>
#include <wb_threads.h>
#include <wb_lang.h>
#include <wb_tools.h>

int main(int argc, char *argv[])
{   
    setlocale(0,"");
    const char *exe_path = argv[0];

    cvar_init();

    cvar_parse_file("wb.cfg");

    if (cvar.g_language != NULL)
    {
        char *path;

        FORMAT(path, "cfg/lang/%s.cfg", cvar.g_language);
        cvar_parse_file(path);
        free(path);
    }

    char *token = NULL;
    char *online_id = NULL;
    char *cmdline = NULL;

    option_parse(argc, argv, &token, &online_id, &cmdline);

    /* Start of -- Legal Notices */

    if (isatty(STDOUT_FILENO))
    {
        xprintf(
            "\nWarfacebot Copyright (C) 2015-2017 Levak Borok\n"
            "This program comes with ABSOLUTELY NO WARRANTY.\n"
            "This is free software, and you are welcome to redistribute it\n"
            "under certain conditions; see AGPLv3 Terms for details.\n");
    }

    /* End of -- Legal Notices */

    idh_init();

    XMPP_REGISTER_QUERY_HDLR();
    XMPP_WF_REGISTER_QUERY_HDLR();

    int wfs = stream_connect(cvar.online_server,
                             cvar.online_server_port);

    if (wfs > 0)
    {
        session_init(wfs, online_id);

        threads_init();

        xmpp_connect(token, online_id);

        threads_run(exe_path, cmdline);

        threads_quit();

        xmpp_close();

        session_free();
    }

    free(token);
    free(online_id);
    free(cmdline);

    xprintf("%s", LANG(wb_closing));

    cvar_free();

    return 0;
}

- This gives Russian input to the console (wb.exe). Sorry about my English.

Levak commented 6 years ago

Thanks for the input. 👍 Will take a look later.

Levak commented 6 years ago

Hi,

This single line doesn't seem to solve anything on my side, it actually makes things worse:

Канал: 
ID профиля: 
Ник: 
Кредиты: 0
Зашел на канал 
Опыт: 
Ранг РМ: 0
Варбаксы: 
Короны: 
Кредиты: 0
Разблокированные предметы: 
Уведомление:  
СМD#

And still can't type anything. In order to test this, I installed RU locale on my Win10.

I tried to give to setlocale() things like ru-RU or ru_RU, .ACP, .65001, .1251, .850, none of them led to positive results.

How are you compiling wb? With MINGW or Cygwin?

ghost commented 6 years ago

CygWin. With this function I got the following(I didn't use 1251 or 65001): v

ghost commented 6 years ago

Levak, try - setlocale(0, "ru_RU.UTF-8");

Okay? Waiting to accomplish your goal.

Levak commented 6 years ago

CygWin

How are you launching warfacebot? Via Cygwin terminal or using wb_launcher.hta?

Levak, try - setlocale(0, "ru_RU.UTF-8");

In Cygwin it indeed fixes the input feedback, but cygwin is not the one used to compile public releases. It's Mingw. And with Mingw, no input is possible with RU keyboard.

On Cygwin I also have some sort of bug from the readline, when I press backspace it inputs a space, when I press Delete it inputs a ~. Trying to update Cygwin at the moment.

ghost commented 6 years ago

I add the line "setlocale(0, "ru_RU.UTF-8");" to the file "wb.c". Create a wb.exe, login via hta-launcher (without 1251), and I have Russian text with Russian input. Create a wb.exe using CYGWIN.

Perhaps you are not working Russian language due to the fact that you have Russian is not present? I have and have my friend the text Russian and core, too,. English also works.

Levak commented 6 years ago

Again. Cygwin works fine with RU input with your fix (setlocale(0, NULL)) but, not with Mingw. In Mingw there is 0 input, and that's the target for public releases.

Same, you might also have colors using Cygwin, while in Mingw there is none.

I'll let this issue open til I figure out what to do exactly with public releases, as publishing Cygwin packages is a no-go for me.