Skip to content

Commit af50289

Browse files
committed
Pull in some additional fixes from Dustin's work on telnet. There is still some more stuff to
go through but this fixes a couple of issues. I also changed the gender options to other instead of neuter.
1 parent 0407890 commit af50289

File tree

5 files changed

+216
-25
lines changed

5 files changed

+216
-25
lines changed

lib/cmds/player/mxp.c

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
inherit M_COMMAND;
2+
3+
string parse_error;
4+
5+
string *usage(void) {
6+
string mode, *lines;
7+
8+
if (this_player()->query_mxp() == 1) {
9+
mode = "on";
10+
} else {
11+
mode = "off";
12+
}
13+
14+
lines = ({ "Usage: ansi[-h] [on|off]" });
15+
lines += ({ "" });
16+
lines += ({ "Used to turn on or off mxp support and show the settings." });
17+
lines += ({ "" });
18+
lines += ({ "Options:" });
19+
lines += ({ "\t-h\tHelp, this usage message." });
20+
lines += ({ "\ton\tTurn on MXP support." });
21+
lines += ({ "\toff\tTurn off MXP support." });
22+
lines += ({ "Examples:" });
23+
lines += ({ "\tmxp on" });
24+
25+
lines += get_alsos();
26+
27+
lines += ({ "" });
28+
lines += ({ "You currently have mxp mode: " + mode });
29+
30+
return lines;
31+
}
32+
33+
setup_alsos() {
34+
add_also("player", "alias");
35+
add_also("player", "clear");
36+
add_also("player", "describe");
37+
add_also("player", "ignore");
38+
add_also("player", "passwd");
39+
add_also("player", "ansi");
40+
41+
add_also("admin", "coloradm");
42+
}
43+
44+
#define GRAMMAR "whitespace=/[ ]+/\n" + \
45+
"TAG=/[A-Z_][A-Z0-9_]*/ \n" + \
46+
"TAG=/NIL/\n" + \
47+
"args: tags ? collect_map\n" + \
48+
"assign: tag '=' values ? wrap_assign\n" + \
49+
"tags: assign\n" + \
50+
"tags: tags assign\n" + \
51+
"tags: tags ',' assign\n" + \
52+
"tags: tags 'and' assign\n" + \
53+
"tag: TAG ? valid_tag_name\n" + \
54+
"values: value_list\n" + \
55+
"value_list: value\n" + \
56+
"value_list: value_list '+' value\n" + \
57+
"value: TAG ? valid_value\n"
58+
59+
/*
60+
* If the arg[0] is a base symbol, it can't be used
61+
* as a custom tag.
62+
*/
63+
mixed *valid_tag_name(mixed * arg) {
64+
if (ANSI_D->query_custom_symbol(arg[0])) {
65+
return arg;
66+
} else {
67+
parse_error = "Invalid tag: " + arg[0];
68+
return nil;
69+
}
70+
}
71+
72+
mixed *valid_value(mixed * arg) {
73+
if ((arg[0] == "NIL") || ANSI_D->query_any_symbol(arg[0])) {
74+
return arg;
75+
} else {
76+
parse_error = "Invalid value: " + arg[0];
77+
return nil;
78+
}
79+
}
80+
81+
mixed *wrap_assign(mixed * arg) {
82+
return ( { ([arg[0]:(arg[2..] - ( { "+" } ))]) } );
83+
}
84+
85+
mixed *collect_map(mixed * arg) {
86+
int i, sz;
87+
mapping result;
88+
89+
result = ([]);
90+
91+
for (i = 0, sz = sizeof(arg); i < sz; i++) {
92+
if (mappingp(arg[i])) {
93+
result += arg[i];
94+
}
95+
}
96+
return ( { result } );
97+
}
98+
99+
static void main(string str) {
100+
mixed *args;
101+
string error;
102+
int i, pos;
103+
104+
if (!alsos) {
105+
setup_alsos();
106+
}
107+
108+
if (empty_str(str)) {
109+
this_player()->more(usage());
110+
return;
111+
}
112+
113+
if (sscanf(str, "-%s", str)) {
114+
this_player()->more(usage());
115+
return;
116+
}
117+
118+
if ((str == "on") || (str == "On") || (str == "1")) {
119+
this_player()->set_mxp(1);
120+
out("%^MXP_LSM%^<!-- Elements to support the Automapper --><!ELEMENT RName FLAG=\"RoomName\"><!ELEMENT RDesc FLAG=\'RoomDesc\'><!ELEMENT RExits FLAG=\'RoomExit\'><!-- The next element is used to define a room exit link that sends the exit direction to the MUD if the user clicks on it --><!ELEMENT Ex \'<SEND>\'><!ELEMENT Announce \'<FONT COLOR=Cyan>\' OPEN><!ELEMENT Gossip \'<FONT COLOR=Green>\' OPEN><!-- the next elements deal with the MUD prompt --><!ELEMENT Prompt FLAG=\"Prompt\"><!ELEMENT Hp FLAG=\"Set hp\"><!ELEMENT MaxHp FLAG=\"Set maxhp\"><!ELEMENT Mana FLAG=\"Set mana\"><!ELEMENT MaxMana FLAG=\"Set maxmana\"><!ELEMENT End FLAG=\"Set end\"><!ELEMENT MaxEnd FLAG=\"Set maxend\"><!ELEMENT RoomX FLAG=\"Set room_x\"><!ELEMENT RoomY FLAG=\"Set room_y\"><!ELEMENT RoomZ FLAG=\"Set room_Z\"><!EL Itm \'<send \"look &text;|drop &text;|wear &text;|wield &text;|drink &text;|unwield &text;|remove &text;\">\'><!EL Click \'<send \"&text;\">\'><!EL ClickP \'<send \"&text;\" PROMPT>\'>%^MXP_LLM%^Turning on MXP...\n");
121+
122+
return;
123+
} else if ((str == "off") || (str == "Off") || (str == "0")) {
124+
this_player()->set_mxp(0);
125+
out("Turning off MXP.\n");
126+
return;
127+
}
128+
}
129+

lib/std/include/telnet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
#define TELOPT_LINEMODE "\x22"
1212
#define LM_MODE "\x01"
1313
#define MODE_EDIT "\x01"
14+
#define TELOPT_MXP "\x5b"

lib/sys/cmds/wiz/gender.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ inherit M_COMMAND;
33
string *usage(void) {
44
string *lines;
55

6-
lines = ({ "Usage: gender [-h] [male|female|neuter]" });
6+
lines = ({ "Usage: gender [-h] [male|female|other]" });
77
lines += ({ " " });
88
lines += ({ "Allows you to set your gender. If no argument is given " });
99
lines += ({ "display your current gender." });
@@ -45,11 +45,11 @@ static void main(string str) {
4545
this_player()->set_gender("male");
4646
write("You are now male.\n");
4747
this_player()->save_me();
48-
} else if (lowercase(str) == "neuter") {
49-
this_player()->set_gender("neuter");
50-
write("You are now neuter.\n");
48+
} else if ((lowercase(str) == "other") || (lowercase(str) == "neuter")) {
49+
this_player()->set_gender("other");
50+
write("You are now other.\n");
5151
this_player()->save_me();
5252
} else {
53-
write("Please use \"male\", \"female\" or \"neuter\" as an argument.\n");
53+
write("Please use \"male\", \"female\" or \"other\" as an argument.\n");
5454
}
5555
}

lib/sys/obj/player.c

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ int verbose_errors; /* 1 for longer error codes */
5858
int display_caught; /* 1 to show caught runtime errors */
5959
static mixed menu_data; /* temp storage for menu system */
6060
int muzzle; /* if 0 we are allowed to shout. */
61+
int mxp;
6162

6263
string query_name(void);
6364

@@ -156,6 +157,14 @@ void set_ansi(int state) {
156157
save_me();
157158
}
158159

160+
int query_mxp(void) {
161+
return mxp | user->mxp_support();
162+
}
163+
164+
void set_mxp(int state) {
165+
mxp = state;
166+
}
167+
159168
void create(void) {
160169
con::create();
161170
bod::create();
@@ -218,6 +227,7 @@ void login_player(void) {
218227
string race;
219228

220229
restore_privs();
230+
set_mxp(0);
221231

222232
/* If we're a wiz, show the wizlog since last login */
223233
if (query_user_type(living_name) > 0) {
@@ -655,15 +665,27 @@ void write_prompt(void) {
655665
result = replace_string(result, "%a", "(none)");
656666
}
657667

658-
result = replace_string(result, "%h", "" + this_player()->query_hp());
659-
result = replace_string(result, "%H", "" + this_player()->query_max_hp());
660-
result = replace_string(result, "%b", "" + this_player()->query_mana());
661-
result = replace_string(result, "%B", "" +
662-
this_player()->query_max_mana());
663-
result = replace_string(result, "%e", "" + this_player()->query_end());
664-
result = replace_string(result, "%E", "" +
665-
this_player()->query_max_end());
666-
out(result + "%^RESET%^ ");
668+
if (query_mxp() == 1) {
669+
result = replace_string(result, "%h", "<Hp>" + this_player()->query_hp() + "</Hp>");
670+
result = replace_string(result, "%H", "<MaxHp>" + this_player()->query_max_hp() + "</MaxHp>");
671+
result = replace_string(result, "%b", "<Mana>" + this_player()->query_mana()+ "</Mana>");
672+
result = replace_string(result, "%B", "<MaxMana>" +
673+
this_player()->query_max_mana() + "</MaxMana>");
674+
result = replace_string(result, "%e", "<End>" + this_player()->query_end()) + "</End>";
675+
result = replace_string(result, "%E", "<MaxEnd>" +
676+
this_player()->query_max_end() + "</MaxEnd>");
677+
out("%^MXP_LSM%^<Prompt>" + result + "</Prompt>%^MXP_LLM%^%^RESET%^");
678+
} else {
679+
result = replace_string(result, "%h", "" + this_player()->query_hp());
680+
result = replace_string(result, "%H", "" + this_player()->query_max_hp());
681+
result = replace_string(result, "%b", "" + this_player()->query_mana());
682+
result = replace_string(result, "%B", "" +
683+
this_player()->query_max_mana());
684+
result = replace_string(result, "%e", "" + this_player()->query_end());
685+
result = replace_string(result, "%E", "" +
686+
this_player()->query_max_end());
687+
out(result + "%^RESET%^ ");
688+
}
667689
}
668690

669691
/* More a set of lines */
@@ -772,9 +794,10 @@ void more_prompt(string arg) {
772794
}
773795

774796
static void do_look_obj(object obj) {
775-
int i, flag;
797+
int i, flag, mxp;
776798
object *objs;
777799

800+
mxp = query_mxp();
778801
this_environment()->event("body_look_at", this_player(), obj);
779802
this_environment()->tell_room(this_player(), this_player()->query_Name() +
780803
" looks at the " + obj->query_id() + ".\n");
@@ -787,10 +810,22 @@ static void do_look_obj(object obj) {
787810
} else if (obj->is_container()) {
788811
flag = 0;
789812
objs = obj->query_inventory();
813+
if (mxp == 1) {
814+
out("%^MXP_LSM%^");
815+
}
790816
write(" \nIt contains:\n");
791817

792818
for (i = 0; i < sizeof(objs); i++) {
793-
write(" " + objs[i]->query_short() + "\n");
819+
if (mxp == 1) {
820+
write(" <send \"get " + objs[i]->query_id() + " from " + obj->query_id() + "\">" +
821+
objs[i]->query_short() + "</send>\n");
822+
} else {
823+
write(" " + objs[i]->query_short() + "\n");
824+
}
825+
}
826+
827+
if (mxp == 1) {
828+
out("%^MXP_LLM%^");
794829
}
795830
}
796831
}

lib/sys/obj/user.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <limits.h>
33
#include <status.h>
44
#include <ports.h>
5+
#include <telnet.h>
56

67
inherit "/sys/lib/runas";
78
inherit telnet "/sys/lib/telnet";
@@ -15,6 +16,7 @@ static int logged_in;
1516
static int data_version;
1617
static int timeout_handle;
1718
private static int auto_admin, auto_wiz;
19+
private int mxp;
1820
object query_player(void);
1921

2022
void create(void) {
@@ -30,6 +32,28 @@ void create(void) {
3032
run_as("nobody");
3133
}
3234

35+
static void telnet_do(int option) {
36+
if (option == TELOPT_MXP[0]) {
37+
telnet::send(IAC + SB + TELOPT_MXP + IAC + SE);
38+
mxp = TRUE;
39+
} else {
40+
::telnet_do(option); /* pass on other options to lower layer */
41+
}
42+
}
43+
44+
static void telnet_dont(int option) {
45+
if (option == TELOPT_MXP[0]) {
46+
telnet::send(IAC + WONT + TELOPT_MXP);
47+
mxp = FALSE;
48+
} else {
49+
::telnet_dont(option); /* pass on other options to lower layer */
50+
}
51+
}
52+
53+
int mxp_support(void) {
54+
return mxp;
55+
}
56+
3357
void _open(mixed * tls) {
3458
if (SITEBAN_D->is_banned(query_ip_number(this_object()))) {
3559
/* site is banned */
@@ -40,15 +64,17 @@ void _open(mixed * tls) {
4064
destruct_object(this_object());
4165
}
4266
telnet::open();
67+
telnet::send(IAC + WILL + TELOPT_MXP);
68+
mxp = FALSE;
4369
send_message("Welcome to " + MUD_NAME + ".\n");
4470
send_message("Running " + LIB_NAME + " " + LIB_VERSION + " on " +
4571
status()[ST_VERSION] + ".\n");
46-
send_message("\n");
72+
send_message("\x1b[7z\n");
4773
send_message(TELNET_D->query_banner());
4874
send_message("\nEnter your name (or 'who', 'guest', 'quit'): ");
4975
send_message(1);
5076

51-
timeout_handle = call_out("login_timeout", 600);
77+
timeout_handle = call_out("login_timeout", 120);
5278
player = clone_object(PLAYER_OB);
5379
player->set_user(this_object());
5480
player->initialize_cmd_path();
@@ -474,7 +500,7 @@ void input_name(string str) {
474500
user_name = usr;
475501

476502
/* Skip ahead for the guest user, no need for password and other stuff */
477-
send_message("Please enter your gender (male/female/neuter) : ");
503+
send_message("Please enter your gender (male/female/other) : ");
478504
player->input_to_object(this_object(), "input_get_gender");
479505
return;
480506
}
@@ -682,13 +708,13 @@ void input_get_email(string str) {
682708
void input_get_website(string str) {
683709
player->set_website(str);
684710

685-
send_message("\nEnter your gender (male/female/neuter) : ");
711+
send_message("\nEnter your gender (male/female/other) : ");
686712
player->input_to_object(this_object(), "input_get_gender");
687713
}
688714

689715
void input_get_gender(string str) {
690716
if (!str || str == "") {
691-
send_message("Please enter your gender (male/female/neuter) : ");
717+
send_message("Please enter your gender (male/female/other) : ");
692718
player->input_to_object(this_object(), "input_get_gender");
693719
return;
694720
}
@@ -698,16 +724,16 @@ void input_get_gender(string str) {
698724
player->set_gender("male");
699725
} else if (str == "f" || str == "female") {
700726
player->set_gender("female");
701-
} else if (str == "n" || str == "neuter") {
702-
player->set_gender("neuter");
727+
} else if (str == "n" || str == "other") {
728+
player->set_gender("other");
703729
} else if (str == "quit") {
704730
write("Goodbye!!!\n");
705731
destruct_object(player);
706732
destruct_object(this_object());
707733
return;
708734
} else {
709-
send_message("Please use 'male', 'female' or 'neuter'.\n");
710-
send_message("Please enter your gender (male/female/neuter) : ");
735+
send_message("Please use 'male', 'female' or 'other'.\n");
736+
send_message("Please enter your gender (male/female/other) : ");
711737
player->input_to_object(this_object(), "input_get_gender");
712738
return;
713739
}

0 commit comments

Comments
 (0)