blob: b5f91f209f1d0fcf4925fffe2d5a750e7392b9ae [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;
Zesstra6fb07c72016-10-28 00:01:42 +0200159 if (sizeof(peers) > 1000)
160 peers = ([:1]);
161 if (stringp(ip))
162 {
MG Mud User88f12472016-06-24 23:31:02 +0200163 // Vollen Datensatz alle ("CRAWL DELAY" / 2) h, daher * 1800.
164 if (peers[ip] > (time() - (to_int(data["CRAWL DELAY"]) || 1) * 1800)) {
165 // this peers asks to often and gets only the minimal dataset
166 ldata = mindata;
167 }
168 else {
169 ldata = data;
170 peers[ip] = time(); // record timestamp
171 }
172 }
173 else
174 ldata = data;
175
176 /* data["WHO"] = implode(map(filter(users(),
177 function status (object o)
178 { return !o->QueryProp(P_INVIS); } ),
179 function string (object o)
180 { return capitalize(o->query_real_name()); } ),
181 "\t" );
182 */
183 ldata["PLAYERS"] = to_string(sizeof(users())-1);
184
185 string reply = "\r\nMSSP-REPLY-START\r\n";
186
187 foreach(string key, string value: ldata) {
188 reply += key + "\t" + value + "\r\n";
189 }
190
191 reply += "MSSP-REPLY-END\r\n";
192 write(reply);
193}
194
195public string get_telnegs_str() {
196 string ip = query_ip_number(previous_object());
197 string res;
198
Zesstra6fb07c72016-10-28 00:01:42 +0200199 if (sizeof(peers) > 1000)
200 peers = ([:1]);
201
MG Mud User88f12472016-06-24 23:31:02 +0200202 if (stringp(ip)) {
203 // Vollen Datensatz alle ("CRAWL DELAY" / 2) h, daher * 1800.
204 if (peers[ip] > (time() - (to_int(data["CRAWL DELAY"]) || 1) * 1800)) {
205 // this peers asks to often and gets only the minimal dataset
206 res = tn_result_min;
207 }
208 else {
209 res = tn_result;
210 peers[ip] = time(); // record timestamp
211 }
212 }
213 else
214 res = tn_result;
215
216 res += convert_tn( (["PLAYERS": to_string(sizeof(users())-1) ]) );
217
218 return res;
219}
220