blob: 58ff7447943dae3a2340703dd99b2fabd40522cd [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001#include <config.h>
2#include <thing/description.h>
3#include <strings.h>
4
5// hosts who asked us in the past and timestamp of last connection which got
6// the full datatset.
7private nosave mapping peers = ([:1]);
8
9/* For a list of official and extended fields:
10 http://www.mudbytes.net/index.php?a=articles&s=MSSP_Fields
11 For a protocal description:
12 http://tintin.sourceforge.net/mssp/
13 */
14
15#define MSSP_VAR 1
16#define MSSP_VAL 2
17
18public string convert_tn(mapping ldata);
19
20protected string list_ports() {
21 int ports = query_mud_port(-1) - 1;
22 string res="23";
23 for(; ports>=0 ; --ports)
24 res += "\t" + to_string(query_mud_port(ports));
25
26 return res;
27}
28
29#define DESCRIPTION \
30 MUDNAME" is a native German LPmud. It was founded in 1992 and has "\
31 "been prospering since. The world features an original fantasy setting "\
32 "with many facets. The 13 domains form a big world with 18000 rooms to "\
Zesstra35296ff2020-01-20 21:56:08 +010033 "explore and several thousand NPCs. You can choose between 8 races and "\
34 "13 classes (guilds). Advancing is done through a combination of "\
MG Mud User88f12472016-06-24 23:31:02 +020035 "exploration points, experience points, class skills, finished "\
36 "adventures and some more. The levels are not limited, current maximum "\
Zesstra35296ff2020-01-20 21:56:08 +010037 "is about 210. After becoming a high level player it's possible to "\
MG Mud User88f12472016-06-24 23:31:02 +020038 "become a wizard and add your own imagination to the game. We are "\
39 "especially proud of attracting a number of visually impaired players "\
40 "who very much enjoy playing a text based online RPG. Thats why we have "\
41 "an option to turn ascii-graphics off. Multiplaying is a bit restricted "\
42 "and scripting is discouraged."
43
44private nosave mapping mindata = ([
45 "NAME" : MUDNAME,
46 "UPTIME" : to_string(__BOOT_TIME__),
47 ]);
48
49private nosave mapping data = mindata + ([
50 "PORT" : list_ports(),
51 "CODEBASE" : _MUDLIB_NAME_+"-"+_MUDLIB_VERSION_,
52 "HOSTNAME" : __HOST_NAME__ + "." + __DOMAIN_NAME__,
53#if MUDHOST == __HOST_NAME__
54// diese Angaben sollen nur gesendet werden, wenn das Mud wirklich auf dem
55// MG-Rechner laeuft und kein Homemud ist.
56 "CRAWL DELAY" : "1",
57 "DESCRIPTION" : DESCRIPTION,
58 "CREATED" : "1992",
59 "ICON" : "http://mg.mud.de/newweb/img/icon.gif",
60 "IP" : "87.79.24.60",
61 "CONTACT" : "mud@mg.mud.de",
62 "WEBSITE" : "http://mg.mud.de/",
63 "AREAS" : "13",
Zesstra35296ff2020-01-20 21:56:08 +010064 "MOBILES" : "7000",
65 "OBJECTS" : "5000",
MG Mud User88f12472016-06-24 23:31:02 +020066 "ROOMS" : "18000",
Zesstra35296ff2020-01-20 21:56:08 +010067 "CLASSES" : "13",
Zesstra2e1065f2020-01-20 22:05:11 +010068 "LEVELS" : "220",
Zesstra35296ff2020-01-20 21:56:08 +010069 "RACES" : "8",
70 "SKILLS" : "170",
MG Mud User88f12472016-06-24 23:31:02 +020071 "MULTICLASSING" : "0",
72 "PLAYERKILLING" : "Restricted",
73 "NEWBIE FRIENDLY" : "1",
74 "ROLEPLAYING" : "Accepted",
75 "WORLD ORIGINALITY": "Mostly Original",
76 "MINIMUM AGE" : "6",
77 "SSL" : "4712",
78 "STATUS" : "Live",
79 "STATUS-NOTES" : "live and running",
80 "PORT-NOTES" : "player ports are 23 and 4711, SSL port is 4712",
Zesstra35296ff2020-01-20 21:56:08 +010081 "QUEST-NOTES" : "We have about 270 Quests and MiniQuests and "
MG Mud User88f12472016-06-24 23:31:02 +020082 "they play an important role in gaining "
83 "levels and skills.",
84 "MULTIPLAYING-NOTES" : "for combat and quests only 2 characters may be active",
85#else
86 "STATUS" : "Alpha",
87 "STATUS-NOTES" : "Homemud for testing puposes",
88#endif
89 "LANGUAGE" : "German",
90 "LOCATION" : "Germany",
91 "FAMILY" : "LPMud",
92 "GENRE" : "Fantasy",
93 "SUBGENRE" : "None",
94 "GAMEPLAY" : "Adventure",
95 "GAMESYSTEM" : "Custom",
96 "INTERMUD" : "IM2-Zebedee",
97 "HELPFILES" : "N/A",
98 "MULTIPLAYING" : "Restricted",
99 "EQUIPMENT SYSTEM" : "Both",
100 "TRAINING SYSTEM" : "Both",
101 "QUEST SYSTEM" : "Integrated",
102 "ZMP" : "0",
103 "ANSI" : "1",
104 "GMCP" : "1",
105 "MCCP" : "0",
106 "MCP" : "0",
107 "MSP" : "0",
108 "MXP" : "0",
109 "PUEBLO" : "0",
110 "VT100" : "1",
111 "XTERM 256 COLORS" : "0",
112 "PAY TO PLAY" : "0",
113 "PAY FOR PERKS" : "0",
114 "HIRING BUILDERS" : "1",
115 "HIRING CODERS" : "1",
116 "CODEBASE-NOTES" : "download daily snapshot of our public base "
Zesstra2e1065f2020-01-20 22:05:11 +0100117 "mudlib at https://mg.mud.de/gerrit/plugins/gitiles/mudlib-public/+/refs/heads/master, "
118 "get our driver at http://www.ldmud.eu/; "
119 "or ask in Morgengrauen if you have questions",
MG Mud User88f12472016-06-24 23:31:02 +0200120 "FAMILY-NOTES" : "Descendant of Nightfall, base for several "
Zesstra2e1065f2020-01-20 22:05:11 +0100121 "german MUDs, uses LDMud-3.6.x",
MG Mud User88f12472016-06-24 23:31:02 +0200122 "HELPFILES-NOTES" : "each basic command, and hundreds of other docs",
123 "MOBILES-NOTES" : "npc's can be cloned, so there can be thousands",
124 "OBJECTS-NOTES" : "objects can be cloned, so there can be thousands",
125 "RESETS-NOTES" : "doesn't apply, LPMud",
126 "MUDPROGS-NOTES" : "doesn't apply, LPMud",
127 "MUDTRIGS-NOTES" : "doesn't apply, LPMud",
128 "RACES-NOTES" : "some additional for non player characters",
129 "SKILLS-NOTES" : "each class/guild and race has its own set of skills",
130 "PLAYERKILLING-NOTES" : "playerkilling is limited to specific rooms",
131/*
132 "ADULT MATERIAL" : "0",
133 "PLAYER CITIES" : "0",
134 "PLAYER CLANS" : "0",
135 "PLAYER CRAFTING" : "0",
136 "PLAYER GUILDS" : "0",
137 "ROOMS-NOTES" : "areas have generated rooms, could be millions",
138 */
139 ]);
140
141
142// cache fuer die telnetneg-basierte variante
143private nosave string tn_result_min = convert_tn(mindata);
144private nosave string tn_result = convert_tn(data);
145
146
147// converts into the array to be sent via telnet suboption negotiation.
148public string convert_tn(mapping ldata) {
149 string res="";
150 foreach(string key, string value: ldata) {
151 res += sprintf("%c%s%c%s", MSSP_VAR, key, MSSP_VAL, value);
152 }
153 return res;
154}
155
156
157public void print_mssp_response() {
158 string ip = query_ip_number(previous_object());
159 mapping ldata;
Zesstra6fb07c72016-10-28 00:01:42 +0200160 if (sizeof(peers) > 1000)
161 peers = ([:1]);
162 if (stringp(ip))
163 {
MG Mud User88f12472016-06-24 23:31:02 +0200164 // Vollen Datensatz alle ("CRAWL DELAY" / 2) h, daher * 1800.
165 if (peers[ip] > (time() - (to_int(data["CRAWL DELAY"]) || 1) * 1800)) {
166 // this peers asks to often and gets only the minimal dataset
167 ldata = mindata;
168 }
169 else {
170 ldata = data;
171 peers[ip] = time(); // record timestamp
172 }
173 }
174 else
175 ldata = data;
176
177 /* data["WHO"] = implode(map(filter(users(),
178 function status (object o)
179 { return !o->QueryProp(P_INVIS); } ),
180 function string (object o)
181 { return capitalize(o->query_real_name()); } ),
182 "\t" );
183 */
184 ldata["PLAYERS"] = to_string(sizeof(users())-1);
185
186 string reply = "\r\nMSSP-REPLY-START\r\n";
187
188 foreach(string key, string value: ldata) {
189 reply += key + "\t" + value + "\r\n";
190 }
191
192 reply += "MSSP-REPLY-END\r\n";
193 write(reply);
194}
195
196public string get_telnegs_str() {
197 string ip = query_ip_number(previous_object());
198 string res;
199
Zesstra6fb07c72016-10-28 00:01:42 +0200200 if (sizeof(peers) > 1000)
201 peers = ([:1]);
202
MG Mud User88f12472016-06-24 23:31:02 +0200203 if (stringp(ip)) {
204 // Vollen Datensatz alle ("CRAWL DELAY" / 2) h, daher * 1800.
205 if (peers[ip] > (time() - (to_int(data["CRAWL DELAY"]) || 1) * 1800)) {
206 // this peers asks to often and gets only the minimal dataset
207 res = tn_result_min;
208 }
209 else {
210 res = tn_result;
211 peers[ip] = time(); // record timestamp
212 }
213 }
214 else
215 res = tn_result;
216
217 res += convert_tn( (["PLAYERS": to_string(sizeof(users())-1) ]) );
218
219 return res;
220}
221