Re: [crossfire] [PATCH 2/2] Character-specific keybinding files
On 11/04/2013 23:35, Mark Wedel wrote: Now a fair question to ask is whether the client should support old server versions or not - IMO, if having support is not hard, it should, but if making it work would be really difficult, then probably not. Although, in that case, the client should see that limitation and print a message saying 'server to old - use an older client on that server' or the like. Considering the small group of players we have, in my opinion it's worth providing backwards compatibility. Metalforge and Invidious have been the de facto public servers, and I imagine that many players have invested significant time on both. Thanks, Kevin Zheng ___ crossfire mailing list crossfire@metalforge.org http://mailman.metalforge.org/mailman/listinfo/crossfire
Re: [crossfire] [PATCH 2/2] Character-specific keybinding files
On 11/ 4/13 05:34 AM, Arvid Brodin wrote: On 2013-11-04 07:38, Mark Wedel wrote: On 11/ 3/13 03:03 PM, Kevin Zheng wrote: On 11/03/2013 13:36, Mark Wedel wrote: Just a question - is there any way to set up 'global' keybindings (eg, those that apply to all characters)? This does seem useful. One possible idea to throw around is to make the key bindings window tabbed, one for per-character and one for global. If there's a conflict, prefer the per-character binding. Of course, this is easier said than done. True on both accounts. Having per character keybindings take preference over global ones would be the correct approach. However, in an ideal world, both are visible, so one could easily see the conflict and make adjustments. Note that it appears this patch introduces a new bug, as posted on the forums: Posted: Sun Nov 03, 2013 6:51 pm Post subject : Compatibility with new character-specific keybindings? I updated my trunk client to the newest version (r19093), which has the character-specific keybindings as a feature. When I logged into Metalforge with the new client, absolutely no keybindings work (not even the default ones). Any keybindings I try to create go to a (null).keys file and do not persist to another login. When I log into netarbeiter (1.70.0), my keybindings work fine. Does this mean the newest trunk client is incompatible with the 1.12 branch? Or am I doing something wrong? -- I suspect the issue is that metalforge is running old code, which predates the new character login logic. As such, the client never has a character name of which to load keybindings for (and I haven't looked, but depending on where the load actually happens, perhaps never load them at all. The names of the characters are returned from the server as a response to AccountPlayersCmd (if I understand correctly), then stored in character_choose_window until play is started with a character, whose name is then stored in cpl.name and is used for loading and saving the keys file. If the name of the chosen character is NULL, that would be passed to strdup(). No check is made since I assumed that it is not possible to start game play without having a list of characters to choose from. I just tried to login at metalforge and the game is instantly started with the character dwarf the dwarf... I.e. the whole login process is skipped? Can anyone describe to me how this works? (I can't test any more now, need to get to work...) metalforge is running an older version of the server, so yes, all of that is skipped, and the server does not support the protocol command for the client to get a list of characters available to the player. So what you see is how it works - you enter the character name, and then password, and that is the login process. Now a fair question to ask is whether the client should support old server versions or not - IMO, if having support is not hard, it should, but if making it work would be really difficult, then probably not. Although, in that case, the client should see that limitation and print a message saying 'server to old - use an older client on that server' or the like. ___ crossfire mailing list crossfire@metalforge.org http://mailman.metalforge.org/mailman/listinfo/crossfire
Re: [crossfire] [PATCH 2/2] Character-specific keybinding files
On 11/ 2/13 04:31 PM, Arvid Brodin wrote: Today, keybindings are saved as ~/.crossfire/keys. That means you cannot have different key bindings for each character. This patch changes that so that keybindings are saved as ~/.crossfire/character-name.keys. So if your character is named Leopold, the keybindings are saved to ~/.crossfire/Leopold.keys. When play is entered with a character, the client tries to load keybindings in the following order: ~/.crossfire/character-name.keys ~/.crossfire/keys client_libdir/def_keys If none of the files are found, it instead uses the default built- in keybindings. Just a question - is there any way to set up 'global' keybindings (eg, those that apply to all characters)? From my reading above, which may not be correct, it suggests that once it finds a matching keys file, it won't go to the next one (so if you have a foobar.keys file, it will load that and won't load anything you have set up in keys). I'm not sure how prevalent it is, but I know for myself that I have some keybindings that would apply to all characters, and it would be a bit of a pain to re-enter them each time a new character is created (now I suppose this can be done as a manual process of having a template file that I manually copy over as I make new characters) That said, certainly have per character keys file is also a good thing, since a lot of things are per character. My only thought here is that it loads up ~/.crossfire/keys regardless, but values in char name.keys override any settings there, and in the bind window, have an option for the keybinding which is something like 'global (all character)' option. ___ crossfire mailing list crossfire@metalforge.org http://mailman.metalforge.org/mailman/listinfo/crossfire
Re: [crossfire] [PATCH 2/2] Character-specific keybinding files
On 2013-11-03 20:36, Mark Wedel wrote: On 11/ 2/13 04:31 PM, Arvid Brodin wrote: Today, keybindings are saved as ~/.crossfire/keys. That means you cannot have different key bindings for each character. This patch changes that so that keybindings are saved as ~/.crossfire/character-name.keys. So if your character is named Leopold, the keybindings are saved to ~/.crossfire/Leopold.keys. When play is entered with a character, the client tries to load keybindings in the following order: ~/.crossfire/character-name.keys ~/.crossfire/keys client_libdir/def_keys If none of the files are found, it instead uses the default built- in keybindings. Just a question - is there any way to set up 'global' keybindings (eg, those that apply to all characters)? From my reading above, which may not be correct, it suggests that once it finds a matching keys file, it won't go to the next one (so if you have a foobar.keys file, it will load that and won't load anything you have set up in keys). I'm not sure how prevalent it is, but I know for myself that I have some keybindings that would apply to all characters, and it would be a bit of a pain to re-enter them each time a new character is created (now I suppose this can be done as a manual process of having a template file that I manually copy over as I make new characters) When you start play with a new character, the client_libdir/def_keys would be loaded, or ~/.crossfire/keys if you have such a file. So you won't start without any keybindings. I have not added a way to configure global keys for all characters. How would you handle the case where a new or modified global key binding conflicts with a character-specific binding (also see below)? Also, I've not added an in-game way to say use the current key bindings for all new characters. This could be done manually by copying a character's .keys file to ~/.crossfire/keys, though. That said, certainly have per character keys file is also a good thing, since a lot of things are per character. My only thought here is that it loads up ~/.crossfire/keys regardless, but values in char name.keys override any settings there, and in the bind window, have an option for the keybinding which is something like 'global (all character)' option. One would have to figure out how the override should be done. Say you have Kevin Zheng's case where the direction keys are Any - i.e. they should work regardless of modifier state. Then add binding for Alt-'b' which conflicts with the Any binding for 'b' - should we then make the direction key 'b' work with any modifier state (None, Ctrl, Shift, Meta, Ctrl+Shift, Ctrl+Alt, Shift+Alt, Ctrl+Shift+Alt, Meta+...) except Alt-'b'? Or should the direction key 'b' be overridden completely? -- Arvid ___ crossfire mailing list crossfire@metalforge.org http://mailman.metalforge.org/mailman/listinfo/crossfire
Re: [crossfire] [PATCH 2/2] Character-specific keybinding files
On 11/03/2013 13:36, Mark Wedel wrote: Just a question - is there any way to set up 'global' keybindings (eg, those that apply to all characters)? This does seem useful. One possible idea to throw around is to make the key bindings window tabbed, one for per-character and one for global. If there's a conflict, prefer the per-character binding. Of course, this is easier said than done. Thanks, Kevin Zheng ___ crossfire mailing list crossfire@metalforge.org http://mailman.metalforge.org/mailman/listinfo/crossfire
[crossfire] [PATCH 2/2] Character-specific keybinding files
Today, keybindings are saved as ~/.crossfire/keys. That means you cannot have different key bindings for each character. This patch changes that so that keybindings are saved as ~/.crossfire/character-name.keys. So if your character is named Leopold, the keybindings are saved to ~/.crossfire/Leopold.keys. When play is entered with a character, the client tries to load keybindings in the following order: ~/.crossfire/character-name.keys ~/.crossfire/keys client_libdir/def_keys If none of the files are found, it instead uses the default built- in keybindings. -- Arvid From 5edd5746ffc9b8cae259b2792d15302569891804 Mon Sep 17 00:00:00 2001 From: Arvid Brodin arv...@kth.se Date: Mon, 28 Oct 2013 02:04:20 +0100 Subject: [PATCH 2/4] Added player character specific keybinding files. Signed-off-by: Arvid Brodin arv...@kth.se --- common/client.h | 13 ++-- common/metaserver.c | 4 -- gtk-v2/src/account.c | 5 ++ gtk-v2/src/create_char.c | 4 ++ gtk-v2/src/gtk2proto.h | 1 + gtk-v2/src/keys.c| 165 --- 6 files changed, 100 insertions(+), 92 deletions(-) diff --git a/common/client.h b/common/client.h index 75d3a54..cb0779a 100644 --- a/common/client.h +++ b/common/client.h @@ -40,8 +40,6 @@ # include dmalloc.h #endif -#define MULTKEYS - #define VERSION_CS 1023 #define VERSION_SC 1029 @@ -349,10 +347,13 @@ typedef struct Player_Struct { uint16 mapxres,mapyres;/** Resolution to draw on the magic * map. Only used in client-specific * code, so it should move there. */ -#ifdef MULTKEYS -charname[ 40 ]; /** Player's name, for player-specific - * key files */ -#endif +char*name; /** Name of PC, set and freed in account.c + * play_character() (using data returned + * from server to AccountPlayersCmd, via + * character_choose window, + * OR in + * send_create_player_to_server() when + * new character created. */ } Client_Player; /** diff --git a/common/metaserver.c b/common/metaserver.c index 3170335..2d68972 100644 --- a/common/metaserver.c +++ b/common/metaserver.c @@ -1041,11 +1041,7 @@ int metaserver_select(char *sel) snprintf(buf, sizeof(buf), Trying to connect to %s:%d, server_name, port); draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_METASERVER, buf); -#ifdef MULTKEYS csocket.fd = init_connection(server_name, port); -#else -csocket.fd = init_connection(server_ip, port); -#endif if (csocket.fd == -1) { draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_METASERVER, Unable to connect to server.); diff --git a/gtk-v2/src/account.c b/gtk-v2/src/account.c index 0ed45b8..59c4d64 100644 --- a/gtk-v2/src/account.c +++ b/gtk-v2/src/account.c @@ -502,6 +502,11 @@ static void play_character(const char *name) SockList_AddString(sl, accountplay ); SockList_AddString(sl, name); SockList_Send(sl, csocket.fd); + +if (cpl.name) +free(cpl.name); +cpl.name = strdup(name); +keybindings_init(); } /** diff --git a/gtk-v2/src/create_char.c b/gtk-v2/src/create_char.c index 567d11a..ef6e709 100644 --- a/gtk-v2/src/create_char.c +++ b/gtk-v2/src/create_char.c @@ -357,6 +357,10 @@ static void send_create_player_to_server() SockList_Send(sl, csocket.fd); +if (cpl.name) +free(cpl.name); +cpl.name = strdup(char_name); +keybindings_init(); } diff --git a/gtk-v2/src/gtk2proto.h b/gtk-v2/src/gtk2proto.h index 26f7c6e..0e894a5 100644 --- a/gtk-v2/src/gtk2proto.h +++ b/gtk-v2/src/gtk2proto.h @@ -112,6 +112,7 @@ extern void animate_inventory(void); extern void animate_look(void); extern void inventory_tick(void); /* keys.c */ +extern void keybindings_init(); extern void keys_init(GtkWidget *window_root); extern void bind_key(char *params); extern void unbind_key(const char *params); diff --git a/gtk-v2/src/keys.c b/gtk-v2/src/keys.c index de9682c..ea64d51 100644 --- a/gtk-v2/src/keys.c +++ b/gtk-v2/src/keys.c @@ -471,24 +471,40 @@ static void init_default_keybindings(void) } } +static int parse_keys_file(char *filename) +{ +int line = 0; +FILE *fp; +char buf[BIG_BUF]; + +CONVERT_FILESPEC_TO_OS_FORMAT(filename); +LOG(LOG_INFO, gtk-v2::init_keys, +Trying to open keybinding file %s, filename); + +fp = fopen(filename, r); +if (fp == NULL) +return -1; + +while (fgets(buf, BIG_BUF, fp)) { +line++; +buf[BIG_BUF - 1] = '\0'; +parse_keybind_line(buf, line); +} + +fclose(fp);