blob: 4c45388a1d169fc05cff1e7e6fb46a85ec7e0f2f [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 "\
33 "explore and several thousand NPCs. You can choose between 7 races and "\
34 "10 classes (guilds). Advancing is done through a combination of "\
35 "exploration points, experience points, class skills, finished "\
36 "adventures and some more. The levels are not limited, current maximum "\
37 "is about 200. After becoming a high level player it's possible to "\
38 "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",
64 "MOBILES" : "2600",
65 "OBJECTS" : "4000",
66 "ROOMS" : "18000",
67 "CLASSES" : "10",
68 "LEVELS" : "200",
69 "RACES" : "7",
70 "SKILLS" : "140",
71 "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",
81 "QUEST-NOTES" : "We have about 200 Quests and MiniQuests and "
82 "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 "
117 "mudlib at ftp://mg.mud.de/Software/MudLib/, "
118 "get our driver at http://www.ldmud.eu/",
119 "FAMILY-NOTES" : "Descendant of Nightfall, base for several "
120 "german MUDs, uses LDMud-3.5.x",
121 "HELPFILES-NOTES" : "each basic command, and hundreds of other docs",
122 "MOBILES-NOTES" : "npc's can be cloned, so there can be thousands",
123 "OBJECTS-NOTES" : "objects can be cloned, so there can be thousands",
124 "RESETS-NOTES" : "doesn't apply, LPMud",
125 "MUDPROGS-NOTES" : "doesn't apply, LPMud",
126 "MUDTRIGS-NOTES" : "doesn't apply, LPMud",
127 "RACES-NOTES" : "some additional for non player characters",
128 "SKILLS-NOTES" : "each class/guild and race has its own set of skills",
129 "PLAYERKILLING-NOTES" : "playerkilling is limited to specific rooms",
130/*
131 "ADULT MATERIAL" : "0",
132 "PLAYER CITIES" : "0",
133 "PLAYER CLANS" : "0",
134 "PLAYER CRAFTING" : "0",
135 "PLAYER GUILDS" : "0",
136 "ROOMS-NOTES" : "areas have generated rooms, could be millions",
137 */
138 ]);
139
140
141// cache fuer die telnetneg-basierte variante
142private nosave string tn_result_min = convert_tn(mindata);
143private nosave string tn_result = convert_tn(data);
144
145
146// converts into the array to be sent via telnet suboption negotiation.
147public string convert_tn(mapping ldata) {
148 string res="";
149 foreach(string key, string value: ldata) {
150 res += sprintf("%c%s%c%s", MSSP_VAR, key, MSSP_VAL, value);
151 }
152 return res;
153}
154
155
156public void print_mssp_response() {
157 string ip = query_ip_number(previous_object());
158 mapping ldata;
159 if (stringp(ip)) {
160 // Vollen Datensatz alle ("CRAWL DELAY" / 2) h, daher * 1800.
161 if (peers[ip] > (time() - (to_int(data["CRAWL DELAY"]) || 1) * 1800)) {
162 // this peers asks to often and gets only the minimal dataset
163 ldata = mindata;
164 }
165 else {
166 ldata = data;
167 peers[ip] = time(); // record timestamp
168 }
169 }
170 else
171 ldata = data;
172
173 /* data["WHO"] = implode(map(filter(users(),
174 function status (object o)
175 { return !o->QueryProp(P_INVIS); } ),
176 function string (object o)
177 { return capitalize(o->query_real_name()); } ),
178 "\t" );
179 */
180 ldata["PLAYERS"] = to_string(sizeof(users())-1);
181
182 string reply = "\r\nMSSP-REPLY-START\r\n";
183
184 foreach(string key, string value: ldata) {
185 reply += key + "\t" + value + "\r\n";
186 }
187
188 reply += "MSSP-REPLY-END\r\n";
189 write(reply);
190}
191
192public string get_telnegs_str() {
193 string ip = query_ip_number(previous_object());
194 string res;
195
196 if (stringp(ip)) {
197 // Vollen Datensatz alle ("CRAWL DELAY" / 2) h, daher * 1800.
198 if (peers[ip] > (time() - (to_int(data["CRAWL DELAY"]) || 1) * 1800)) {
199 // this peers asks to often and gets only the minimal dataset
200 res = tn_result_min;
201 }
202 else {
203 res = tn_result;
204 peers[ip] = time(); // record timestamp
205 }
206 }
207 else
208 res = tn_result;
209
210 res += convert_tn( (["PLAYERS": to_string(sizeof(users())-1) ]) );
211
212 return res;
213}
214