Aliases and partial player matches

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

User avatar
itsrachelfish
Developers
Developers
Posts: 50
Joined: 27 Feb 2012, 12:50
Noob?: No

Aliases and partial player matches

#1 Post by itsrachelfish »

It's kind of annoying when inviting people into parties and guilds you have to say "party request [player ID]"

First, it'd be nice to have the option of saying "party invite", which would map to "party request"
Second, it'd be nice if invites would match partial player names using Match::player()

Also, is there any reason Match::player() isn't used for the follow command as well? Sure, the person you're trying to follow might not be on your screen, but in that case it would just default to the exact string you specified.
Tired of waiting for answers on the forums?
Want to talk to OpenKore experts?

Hang out on the #OpenKore IRC!
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Aliases and partial player matches

#2 Post by EternalHarvest »

"party request" accepts player names (as in client's "/invite" command), not just IDs.
First, it'd be nice to have the option of saying "party invite", which would map to "party request"
Maybe. It's not the only slightly weird command naming we have.
Second, it'd be nice if invites would match partial player names using Match::player()
Also, is there any reason Match::player() isn't used for the follow command as well? Sure, the person you're trying to follow might not be on your screen, but in that case it would just default to the exact string you specified.
You can possibly get a wrong player when matching partial names. Autocompletion of player names doesn't help much?
User avatar
itsrachelfish
Developers
Developers
Posts: 50
Joined: 27 Feb 2012, 12:50
Noob?: No

Re: Aliases and partial player matches

#3 Post by itsrachelfish »

EternalHarvest wrote:
Second, it'd be nice if invites would match partial player names using Match::player()
Also, is there any reason Match::player() isn't used for the follow command as well? Sure, the person you're trying to follow might not be on your screen, but in that case it would just default to the exact string you specified.
You can possibly get a wrong player when matching partial names. Autocompletion of player names doesn't help much?
It's pretty rare to get erroneous player matches even in a very crowded area, it's all a matter of how lazy you are. If you type "party invite f" then yeah, you might match the wrong person but it's totally your fault. Even if you only type the first three letters of someone's name the odds of matching the wrong player are 1 in 1322 (1 in 26 + 36 ^ 2). Actually, that only includes first character alpha with following characters alphanumeric.

Anyway, that's not the point. The point is it's a hassle to type pl, find the player's name you want to invite, then type party request [id].

Imagine these scenarios:
  • 1. You're in a crowded area with 50 people, you have to look down the whole list to find your friend's ID or wait for them to say something in public chat.
    2. You're out leveling, or sitting at your guild spot in town, there's not many players around so the odds of a mis-match are almost zero.
    3. You're in an intense leveling session with a few people and tons of mobs. A new player comes who wants to join your party. All the skills and damage are scrolling so fast they make reading the output of pl impossible.
Now imagine this scenario:
  • 1. You invite the wrong person. ...Kick them?
But don't worry— I'll add this feature with a config option for it to be enabled/disabled.
What do you think, enabled or disabled by default?
Tired of waiting for answers on the forums?
Want to talk to OpenKore experts?

Hang out on the #OpenKore IRC!
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Aliases and partial player matches

#4 Post by EternalHarvest »

My point is that "party request" already accepts full player names, and there is even autocompletion for these names, so do you really need partial maching here?
User avatar
itsrachelfish
Developers
Developers
Posts: 50
Joined: 27 Feb 2012, 12:50
Noob?: No

Re: Aliases and partial player matches

#5 Post by itsrachelfish »

What do you mean by autocompletion?

Code: Select all

pl
-----------Player List-----------
#    Name                                Sex   Lv  Job         Dist  Coord
0    Renna Twilight [lnfinity]           Girl  150 Sura        14.9  (55, 64)
1    MasterCoon [Smokies]                Girl  150 Sura        6.1   (50, 75)
2    Maybee [RagnaStats]                 Girl  73  Hunter      5.1   (49, 73)
3    Nico Ishrael [Unbound]              Boy   115 Rune Knight 17.8  (55, 60)
Total players: 4
---------------------------------
party request ma
Join request failed: the character is not currently online or does not exist.
party request Ma
Join request failed: the character is not currently online or does not exist.
party request May
Join request failed: the character is not currently online or does not exist.
party request Maybe
Join request failed: the character is not currently online or does not exist.
Tired of waiting for answers on the forums?
Want to talk to OpenKore experts?

Hang out on the #OpenKore IRC!
User avatar
itsrachelfish
Developers
Developers
Posts: 50
Joined: 27 Feb 2012, 12:50
Noob?: No

Re: Aliases and partial player matches

#6 Post by itsrachelfish »

Talking to harvest on IRC, apparently tab-completion of player names is a Wx specific feature.
Tired of waiting for answers on the forums?
Want to talk to OpenKore experts?

Hang out on the #OpenKore IRC!
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Aliases and partial player matches

#7 Post by EternalHarvest »

itsrachelfish wrote:Talking to harvest on IRC, apparently tab-completion of player names is a Wx specific feature.
Seems to be currently implemeted only in Wx, yes.
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Aliases and partial player matches

#8 Post by EternalHarvest »

That's what I've got so far for autocompletion in Console::Unix.
Problems: segfaults when calling to Commands::complete; src/test/SConscript doesn't work well (disabled here).

Code: Select all

Index: src/auto/XSTools/unix/consoleui.cpp
===================================================================
--- src/auto/XSTools/unix/consoleui.cpp	(revision 8042)
+++ src/auto/XSTools/unix/consoleui.cpp	(working copy)
@@ -41,6 +41,10 @@
 	static void lineRead(char *line) {
 		ConsoleUI::getInstance()->lineRead(line);
 	}
+
+	static char **complete(const char *text, int start, int end) {
+		return ConsoleUI::getInstance()->complete(text, start, end);
+	}
 };
 
 
@@ -68,6 +72,25 @@
 	pthread_cond_destroy(&outputCond);
 }
 
+char **
+ConsoleUI::complete(const char *text, int start, int end) {
+	int i, count;
+	static char *args[] = {(char *) text};
+	char **matches;
+
+	dSP;
+	PUSHMARK(SP);
+	call_pv("Commands::complete", G_DISCARD | G_NOARGS);
+	//count = call_argv("Commands::complete", G_ARRAY, args);
+	//SPAGAIN;
+	//for (i = 0; i < count; i++) {
+	//	POPs;
+	//}
+
+	matches = (char **)NULL;
+	return matches;
+}
+
 void
 ConsoleUI::lineRead(char *line) {
 	if (line == NULL) {
@@ -104,6 +127,8 @@
 
 void *
 ConsoleUI::threadMain(void *arg) {
+	//rl_bind_key('\t', ConsoleUICallbacks::complete);
+	rl_attempted_completion_function = ConsoleUICallbacks::complete;
 	rl_callback_handler_install("", ConsoleUICallbacks::lineRead);
 	while (!quit) {
 		while (canRead()) {
Index: src/auto/XSTools/unix/consoleui.h
===================================================================
--- src/auto/XSTools/unix/consoleui.h	(revision 8042)
+++ src/auto/XSTools/unix/consoleui.h	(working copy)
@@ -1,6 +1,10 @@
 #ifndef _CONSOLEUI_H_
 #define _CONSOLEUI_H_
 
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
 #include <pthread.h>
 #include <queue>
 
@@ -32,6 +36,7 @@
 	void *threadMain(void *arg);
 	void processOutput();
 	void lineRead(char *line);
+	char **complete(const char *text, int start, int send);
 	bool canRead();
 	static void cleanup();
 
Index: src/test/consoleui-test.cpp
===================================================================
--- src/test/consoleui-test.cpp	(revision 8042)
+++ src/test/consoleui-test.cpp	(working copy)
@@ -1,3 +1,7 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
 #include "consoleui.h"
 #include <stdio.h>
 #include <unistd.h>
Index: SConstruct
===================================================================
--- SConstruct	(revision 8042)
+++ SConstruct	(working copy)
@@ -9,10 +9,12 @@
 # header files.
 # Example: EXTRA_INCLUDE_DIRECTORIES = ['/foo', '/bar']
 EXTRA_INCLUDE_DIRECTORIES = []
+EXTRA_INCLUDE_DIRECTORIES = ['/usr/local/include', '/usr/lib/perl/5.10/CORE']
 
 # Extra directories in which the linker should search for libraries.
 # Example: EXTRA_LIBRARY_DIRECTORIES = ['/opt/foo/lib', '/tmp/bar/lib']
 EXTRA_LIBRARY_DIRECTORIES = []
+EXTRA_LIBRARY_DIRECTORIES = ['/usr/local/lib']
 
 # Extra arguments to be passed to the compiler during the compilation
 # stage (not during the linking stage).
@@ -349,5 +351,5 @@
 sconscripts = []
 if not int(ARGUMENTS.get('TESTS_ONLY', 0)):
 	sconscripts += ['src/auto/XSTools/SConscript']
-sconscripts += ['src/test/SConscript']
+#sconscripts += ['src/test/SConscript']
 SConscript(sconscripts)