blob: 2f4692753eb7f324267489c8b6697d979583954b [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// transport.c -- Basisklasse fuer Schiffe und aehnliche Transporter
4//
5// $Id: transport.c 9400 2015-12-11 21:56:14Z Zesstra $
Zesstra@Morgengrauen2315aa12016-10-30 22:36:26 +01006#pragma strong_types,rtt_checks
MG Mud User88f12472016-06-24 23:31:02 +02007#pragma range_check
8#pragma no_clone
MG Mud User88f12472016-06-24 23:31:02 +02009
10inherit "/std/thing/moving";
11inherit "/std/room";
12
13#include <properties.h>
14#include <moving.h>
15#include <defines.h>
16#include <language.h>
17#include <transport.h>
18#include <regexp.h>
Zesstra179db0d2016-11-26 13:13:41 +010019#include <hook.h>
20
MG Mud User88f12472016-06-24 23:31:02 +020021
22/* transport.c
23 *
24 * Ueberarbeitete und
25 * erweiterte Version : Tilly@MorgenGrauen, 10.01.02
26 * Basierend auf : transport.c@SilberLand (Woody@SilberLand), 05.12.99
27 * Basierend auf : Hates und Rumatas generisches Transport Objekt
28 * MorgenGrauen 15.02.93
29 */
30
31/*
32 ********************* Variablen *********************
33 */
34
35// TODO: langfristig waer ja private schoen...
36//
37// Datenstruktur von 'route' (bei HP_ROOM)
38// 0 ({string ID, : HP_ROOM
39// 1 string room, : Dateiname Zielraum
40// 2 int stay, : Dauer Haltezeit
41// 3 int next, : Dauer naechste Fahrtzeit
42// 4 string code, : Haltestellenname fuer QueryArrived
43// 5 mixed dest, : Haltestellen-IDs fuer HasRoute (reise nach)
44// 6 mixed deststr }): unbenutzt.
45//
46// Datenstruktur von 'route' (bei HP_MSG, HP_FUN)
47// 0 ({string ID, : HP_MSG
48// 1 string message, : Meldung oder string fun : Funktionsname
49// 2 int next}) : Dauer bis zum naechsten Ereignis
50nosave mixed *route; /* Liste der Haltepunkte. */
51nosave int rpos; /* Momentane Position in obiger Liste. */
52nosave string roomCode; /* Code des aktuellen Raumes (oder 0). */
Zesstrae805e3a2018-02-12 19:48:06 +010053// Letzter Spielerkontakt. Das muss != 0 sein (sonst funktioniert der
54// Mechanismus zum Fortsetzen der Route nach einer Pause nicht ordentlich,
55// daher wird es auf 1 initialisiert.
56nosave int meet_last_player = 1;
Zesstra7842b8e2019-07-04 21:55:39 +020057// Dauer der Route
58nosave int route_time;
Zesstra179db0d2016-11-26 13:13:41 +010059
60private void unsubscribe_init();
61private int subscribe_init();
Zesstra72843372018-02-12 21:34:49 +010062void changeHp();
MG Mud User88f12472016-06-24 23:31:02 +020063
64/*
65 ********** Management der builtin-properties **********
66 */
67
68string _query_short()
69{
70 if (roomCode) return Query(P_SHORT);
71 return 0;
72}
73
74mixed _query_transparent()
75{
76 if (roomCode) return Query(P_TRANSPARENT);
77 return 0;
78}
79
Zesstra179db0d2016-11-26 13:13:41 +010080static mixed *_set_route(mixed *r) { return route = r; }
81static mixed *_query_route() { return route; }
82static int _query_mnpc_last_meet() { return meet_last_player; }
MG Mud User88f12472016-06-24 23:31:02 +020083
84/*
85 **************** Zugriffsfunktionen ***************
86 */
87
Zesstra179db0d2016-11-26 13:13:41 +010088public void Halt()
MG Mud User88f12472016-06-24 23:31:02 +020089{
Zesstra179db0d2016-11-26 13:13:41 +010090 // stop, but keep rpos counter.
MG Mud User88f12472016-06-24 23:31:02 +020091 while (remove_call_out( "changeHp" )>-1);
92 while (remove_call_out( "disconnect" )>-1);
93}
94
95// Aktualisiert/Setzt die Route im TravelD, wenn erlaubt (d.h. kein
96// P_NO_TRAVELING)
97private void ReportRoute()
98{
99 if(!QueryProp(P_NO_TRAVELING))
100 {
101 mixed tmp = filter(route, function int (mixed arr)
102 {
103 return arr[0] == HP_ROOM;
104 } );
105 string *route = map(tmp, function string (mixed arr)
106 { return arr[1]; }
107 );
108 TRAVELD->AddRoute(object_name(this_object()),route);
109 }
110}
111
Zesstra179db0d2016-11-26 13:13:41 +0100112public varargs void Start(int pos)
MG Mud User88f12472016-06-24 23:31:02 +0200113{
114 Halt();
Zesstra5d2ace02017-06-20 23:21:36 +0200115 // negative pos sind ein Fehler
116 if (pos<0)
117 raise_error(sprintf("Start(): Positionszaehler < 0: %d\n",pos));
118
119 // wenn pos zu gross fuer die Route ist, rpos auf Ende der Route setzen
120 // (i.e. sizeof(route)-1), damit bei der naechsten Bewegung am Anfang der
121 // Route begonnen wird.
122 rpos = min(pos, sizeof(route)-1);
123
MG Mud User88f12472016-06-24 23:31:02 +0200124 // Tell TRAVELD our current route
125 ReportRoute();
Zesstrac786fee2018-02-12 20:31:29 +0100126 // changeHp() inkrementiert zu Beginn rpos um 1. D.h. damit wir keinen
127 // Haltepunkt ueberspringen, muss dieses vorweg kompensiert werden. Da dies
128 // wiederum den Transporter aber ggf. buggen laesst (rpos<0), darf das
129 // changeHp() hier nicht asynchron per call_out gerufen werden.
130 --rpos;
131 changeHp();
MG Mud User88f12472016-06-24 23:31:02 +0200132}
133
Zesstra179db0d2016-11-26 13:13:41 +0100134// continues the current route at the point we stopped.
135public int Continue()
136{
137 if (find_call_out("changeHp") == -1
138 && find_call_out("disconnect") == -1)
139 {
Zesstra019987a2017-10-24 22:36:08 +0200140 // Nach einer Pause wird die Route am aktuellen Haltepunkt fortgesetzt
141 // (im Regelfall also am Ende der Route). Am Routenende wird auch
142 // geprueft, wann der letzte Spielerkontakt war. Das darf nach einem
143 // Continue() aber nicht passieren, sonst wuerde der Transporter ggf.
144 // sofort wieder anhalten.
145 meet_last_player*=-1; // neg. vorzeichen als Markierung
Zesstra179db0d2016-11-26 13:13:41 +0100146 unsubscribe_init();
147 Start(rpos);
148 return 1;
149 }
150 return 0;
151}
152
153// pauses the transporter temporarily in a way that it continues along its
154// route as soon as a living enters one of the stop points. If that is not
155// possible, we do nothing.
156public int Pause()
157{
158 // ok, stop
159 if (subscribe_init() == 1)
160 {
161 Halt();
162 return 1;
163 }
164 return 0;
165}
166
MG Mud User88f12472016-06-24 23:31:02 +0200167void SetTravelCmds()
168{
169 if (pointerp(QueryProp(P_LEAVECMDS)))
170 AddCmd(QueryProp(P_LEAVECMDS),"GoOutside");
171 if (pointerp(QueryProp(P_ENTERCMDS)))
172 AddCmd(QueryProp(P_ENTERCMDS),"GoInside");
173 if (pointerp(QueryProp(P_TRAVEL_CMDS)))
174 AddCmd(QueryProp(P_TRAVEL_CMDS),"GoInAndOutside");
175 return;
176}
177
178mixed HasRoute(mixed dest)
179{
180 int i,s,z;
181 string str;
182 object ob;
183 mixed harb;
184
185 s = sizeof(route);
186
187 for (i = rpos;i <= rpos+s-1;i++)
188 {
189 if (route[i%s][0] == HP_ROOM)
190 {
191 if (member(route[i%s][5],dest) != -1 &&
192 objectp(ob=load_object(route[i%s][1])) &&
193 pointerp(harb=ob->QueryProp(P_HARBOUR)) &&
194 sizeof(harb))
195 {
196 return ({ route[i%s][1], harb[0] });
197 }
198 }
199 }
200 return 0;
201}
202
203public varargs void AddRoute(string room, int stay, int next,
204 string harbour_desc, string|string* dest_ids, string deststr)
205{
206 // Daten aus dem Zielanleger abfragen.
207 <string|string*>* harbour = room->QueryProp(P_HARBOUR)||({});
208 string* harbour_ids = ({});
209
210 // IDs des Zielanlegers fuer Syntaxpruefung
211 if ( sizeof(harbour)==2 )
212 {
213 if ( pointerp(harbour[1]) )
214 harbour_ids = harbour[1];
215 else
216 harbour_ids = ({harbour[1]});
217 }
218
219 // <dest_ids> in ein Array umwandeln, ist dann ggf. leer
220 if ( !dest_ids )
221 {
222 dest_ids = ({});
223 }
224 if ( stringp(dest_ids) )
225 {
226 dest_ids = ({dest_ids});
227 }
228
229 // explizit angegebene IDs stehen jetzt in <dest_ids>, die IDs des
230 // Zielhafens aus P_HARBOUR werden addiert.
231 dest_ids += harbour_ids;
232
233 // Ist <dest> immer noch leer, versuchen wir, aus <harbour_desc> ein paar
234 // Stichwoerter zu erzeugen, die man als Zielangabe in der Syntax
235 // "reise nach <ziel>" verwenden kann.
236 if ( !sizeof(dest_ids) )
237 {
238 // Grossgeschriebene Begriffe in <harbour_desc> in <dest> eintragen. Dazu:
239 // 1) <code> erstmal so zerschneiden, dass alle ueblichen Satzzeichen
240 // rausfliegen (es gibt Transporter, die sowas in <harbour_desc>
241 // uebergeben).
242 dest_ids = regexplode(harbour_desc, "[(),.;:&\+_ ]",
243 RE_OMIT_DELIM|RE_GLOBAL);
244 // 2a) So filtern, dass nur grossgeschriebene Woerter uebrig bleiben,
245 // von 1) uebriggebliebene Leerstrings gleich mit wegwerfen.
246 // 2b) Ergebnis kleinschreiben, damit die Syntaxpruefung damit arbeiten
247 // kann.
248 dest_ids = map( filter(dest_ids, function int (string key) {
249 return (key!="" && key[0]>='A' && key[0]<='Z');
250 }), #'lower_case);
251 }
252 // Sollte <dest> jetzt immer noch leer sein, wurde an allen drei Stellen
253 // nichts oder nur Muell uebergeben.
254 if ( !sizeof(dest_ids) )
255 {
256 raise_error("Transporterfehlfunktion in AddRoute(): Identifikations"
257 "matrix unzureichend definiert. Transporter unbenutzbar fuer "
258 "Spieler. Bitte mindestens eine Ziel-ID via P_HARBOUR oder als "
259 "Argument to AddRoute().");
260 }
261 route += ({ ({ HP_ROOM, room, stay, next, harbour_desc, dest_ids,
262 deststr }) });
Zesstra7842b8e2019-07-04 21:55:39 +0200263 route_time += stay + next;
MG Mud User88f12472016-06-24 23:31:02 +0200264}
265
Zesstra7842b8e2019-07-04 21:55:39 +0200266varargs void AddMsg(string msg, int next)
MG Mud User88f12472016-06-24 23:31:02 +0200267{
Zesstra7842b8e2019-07-04 21:55:39 +0200268 route += ({ ({ HP_MSG, msg, next }) });
269 route_time += next;
MG Mud User88f12472016-06-24 23:31:02 +0200270}
271
Zesstra7842b8e2019-07-04 21:55:39 +0200272void AddFun(string fun, int next)
273{
274 route += ({ ({ HP_FUN, fun, next }) });
275 route_time += next;
276}
MG Mud User88f12472016-06-24 23:31:02 +0200277
278string QueryArrived() { return roomCode; }
279
280mixed* QueryPosition()
281{
282 return ({ route[rpos][1],route[(rpos+1)<sizeof(route)?(rpos+1):0][1] });
283}
284
285object* QueryPassengers()
286{
287 return filter(all_inventory(),#'query_once_interactive);
288}
289
290varargs string *QueryHarbours(int textflag)
291{
292 string *ret = ({});
293
294 foreach( mixed* entry : route )
295 {
296 if ( entry[0] == HP_ROOM )
297 {
298 if ( textflag )
299 {
300 string *hp_ids = entry[1]->QueryProp(P_HARBOUR)[1];
301 if (pointerp(hp_ids) && sizeof(hp_ids))
302 {
303 string *h = map( explode(hp_ids[0]," "), #'capitalize);
304 ret += ({ implode(h, " ") });
305 }
306 }
307 else
308 {
309 ret += ({ entry[1] });
310 }
311 }
312 }
313 return ret;
314}
315
316// beim zerstoeren sollte auch die route und der Transporter aus dem traveld
317// abgemeldet werden.
318public varargs int remove(int silent)
319{
320 TRAVELD->RemoveTransporter(this_object());
321 return ::remove(silent);
322}
323
324void RemoveRoute()
325{
326 Halt();
327 route = ({ });
328 rpos = 0;
Zesstra7842b8e2019-07-04 21:55:39 +0200329 route_time = 0;
MG Mud User88f12472016-06-24 23:31:02 +0200330 TRAVELD->RemoveTransporter(this_object());
331}
332
333varargs int Enter(object who)
334{
335 string *emsg;
336 mixed efail;
337
338 if (!objectp(who)) who = this_player();
339 if (environment(who) == this_object())
340 {
341 tell_object(who,"Da bist Du doch bereits, schon vergessen?\n");
342 return 1;
343 }
344 if (!QueryArrived()) return 0;
345 if (QueryProp(P_MAX_PASSENGERS) &&
346 (sizeof(QueryPassengers()) >= QueryProp(P_MAX_PASSENGERS)))
347 {
348 if (pointerp(efail=QueryProp(P_ENTERFAIL)))
349 {
350 if (sizeof(efail) == 2)
351 tell_room(this_object(),who->Name(WER,2)+" "+process_string(efail[1])+
352 ".\n",({who}));
353 tell_object(who,process_string(efail[0])+".\n");
354 }
355 else if (stringp(efail))
356 tell_object(who,process_string(efail)+".\n");
357 else if (closurep(efail)) funcall(efail);
358 return 1;
359 }
360
361 tell_object(who,"Du betrittst "+name(WEN,1)+".\n");
362 if (pointerp(emsg=QueryProp(P_ENTERMSG)) && sizeof(emsg) == 2)
363 return who->move(this_object(),M_GO,"",process_string(emsg[0]),
364 process_string(emsg[1]));
365 return who->move(this_object(),M_GO,
366 name(WEN,1),"betritt","kommt herein");
367}
368
369varargs int Leave(object who)
370{
371 string *lmsg;
372 mixed lfail;
373
374 if (!objectp(who)) who = this_player();
375 if (environment(who) != this_object())
376 {
377 if (QueryArrived())
378 {
379 tell_object(who,"Dafuer muesstest Du erstmal dort sein.\n");
380 return 1;
381 }
382 return 0;
383 }
384 if (!QueryArrived())
385 {
386 if (lfail=QueryProp(P_LEAVEFAIL))
387 {
388 if (pointerp(lfail) && sizeof(lfail))
389 {
390 if (sizeof(lfail) == 2)
391 tell_room(this_object(),who->Name(WER,2)+" "+process_string(
392 lfail[1])+".\n",({who}));
393 tell_object(who,process_string(lfail[0])+".\n");
394 }
395 else if (stringp(lfail))
396 tell_object(who,process_string(lfail)+".\n");
397 else if (closurep(lfail)) funcall(lfail);
398 return 1;
399 }
400 tell_object(who,"Fehler beim Verlassen des Transporters.\n"
401 "Bitte zustaendigen Magier verstaendigen.\n");
402 return 1;
403 }
404
405 if (who->QueryProp(P_TRAVEL_INFO)) who->SetProp(P_TRAVEL_INFO,0);
406 tell_object(who,"Du verlaesst "+name(WEN,1)+".\n");
407 if (pointerp(lmsg=QueryProp(P_LEAVEMSG)) && sizeof(lmsg) == 2)
408 return who->move(environment(),M_GO,"",process_string(lmsg[0]),
409 process_string(lmsg[1]));
410 return who->move(environment(),M_GO,
411 name(WEN,1),"verlaesst","kommt herein");
412}
413
414/*
415 ****************** Internal Functions ******************
416 */
417
418static int GoInside(string str)
419{
420 _notify_fail("Was moechtest Du denn genau?\n");
421 if (stringp(str) && id(str)) {
422 Enter();
423 return 1;
424 }
425 return 0;
426}
427
428static int GoOutside(string str)
429{
430 _notify_fail("Was moechtest Du denn genau?\n");
431 if (stringp(str) && id(str)) {
432 Leave();
433 return 1;
434 }
435 return 0;
436}
437
438static int GoInAndOutside(string str)
439{
440 string to;
441
442 _notify_fail("Was moechtest Du denn genau?\n");
443 if (!sizeof(str)) return 0;
444 if ((sscanf(str,"auf %s",to) == 1 || sscanf(str,"in %s",to) == 1) && id(to))
445 return Enter(),1;
446 if ((sscanf(str,"von %s",to) == 1 || sscanf(str,"aus %s",to) == 1) && id(to))
447 return Leave(),1;
448 return 0;
449}
450
451protected void create()
452{
453 ::create();
454
455 route = ({});
456
457 SetProp(P_LEAVEFAIL,"Das ist momentan viel zu gefaehrlich");
458 SetProp(P_ENTERFAIL,"Dort ist kein Platz mehr fuer Dich");
459 SetProp(P_TRANSPARENT,1);
460
461 AddId("Transporter");
Zesstra179db0d2016-11-26 13:13:41 +0100462
MG Mud User88f12472016-06-24 23:31:02 +0200463 call_out("SetTravelCmds",1);
464}
465
466static varargs void disconnect(int change, int change_time)
467{
468 object room;
469 mixed *departmsg;
470
471 departmsg = QueryProp(P_DEPARTMSG);
472
473 if ((room = environment()) && pointerp(departmsg))
474 {
475 tell_room(this_object(),process_string(departmsg[0]));
476 tell_room(room,process_string(departmsg[1]));
477 }
478
479 roomCode = 0;
480
481 if (change) call_out("changeHp",change_time);
482}
483
484static varargs void connect(string room, string code)
485{
486 mixed *arrivemsg, *t;
487 object *trav, ob;
488 string *trs, *msgs;
489 int i;
490
491 if (roomCode) disconnect();
492
493 roomCode = code?code:"";
494
495 if (catch(move(room,M_SILENT|M_NOCHECK);publish))
496 {
497 roomCode = 0;
498 return;
499 }
500
501 arrivemsg = QueryProp(P_ARRIVEMSG);
502
503 if (pointerp(arrivemsg))
504 {
505 tell_room(this_object(),process_string(arrivemsg[0]));
506 tell_room(room,process_string(arrivemsg[1]));
507 }
508
509 trav = filter(all_inventory(this_object()),#'living);
510
511 i = sizeof(trav);
512 while(i--)
513 {
514 if (pointerp(t = trav[i]->QueryProp(P_TRAVEL_INFO))&&
515 t[0]==this_object()&&t[2]==room)
516 {
517 if (trav[i]->InFight())
518 tell_object(trav[i],break_string("Du solltest Deinen Kampf "
519 "schnell beenden,denn eigentlich wolltest Du hier "
520 "aussteigen.",78));
521 else
522 Leave(trav[i]);
523 if (environment(trav[i])!=this_object())
524 trav[i]->SetProp(P_TRAVEL_INFO,0);
525 }
526 }
527 trav = filter(all_inventory(find_object(room))-trav,#'living);
528 i=sizeof(trav);
529 while(i--)
530 {
531 if (objectp(trav[i]) && pointerp(t = trav[i]->QueryProp(P_TRAVEL_INFO))&&
532 t[0] == environment(trav[i]) && t[1] == this_object())
533 {
534 if ( trav[i]->InFight() )
535 tell_object(trav[i],
536 break_string("Du solltest Deinen Kampf schnell beenden, denn "
537 "eigentlich wolltest Du mit "+name(WEM,1)+
538 " reisen.",78));
539 else
540 Enter(trav[i]);
541 if (environment(trav[i]) == this_object())
542 {
543 t[0] = this_object();
544 trav[i]->SetProp(P_TRAVEL_INFO,t);
545 }
546 }
547 }
548}
549
550// this object never performs any clean-up, the driver should not call it
551// again.
552int clean_up(int arg) { return 0; }
553
Zesstra5b71ebb2018-03-07 20:50:35 +0100554public varargs void init(object origin)
Zesstra179db0d2016-11-26 13:13:41 +0100555{
Zesstra5b71ebb2018-03-07 20:50:35 +0100556 "*"::init(origin);
Zesstra179db0d2016-11-26 13:13:41 +0100557 // if we have player contact (even if the player is just in the same
558 // environment), we update the time.
559 if (this_player() && query_once_interactive(this_player()))
Bugfix4df578b2019-03-13 18:36:59 +0100560 {
561 meet_last_player = time();
562 // Wenn jemand in uns ist, auch falls noetig die Route fortsetzen,
563 // denn wir haben natuerlich nicht H_HOOK_INIT in uns selbst abonniert.
564 if(environment(PL)==ME)
565 Continue();
566 }
Zesstra179db0d2016-11-26 13:13:41 +0100567}
568
569// we try to continue our route once some living triggers init.
570private mixed InitHookCallback(object source, int hookid, mixed hookdata)
571{
572 if (hookid == H_HOOK_INIT && previous_object() == source)
573 Continue();
574
575 return ({H_NO_MOD, hookdata});
576}
577
578// subscribes to H_HOOK_INIT in all rooms along the route
Zesstra658871d2019-07-04 21:34:02 +0200579// == 1 for success, < -1 if not (at least one hook failed, all registration
580// were already subscribed).
Zesstra179db0d2016-11-26 13:13:41 +0100581private int subscribe_init()
582{
583 // subscribe to the H_HOOK_INIT of all rooms in the route...
Zesstra179db0d2016-11-26 13:13:41 +0100584 foreach(mixed* arr : route)
585 {
586 if (arr[0] == HP_ROOM)
587 {
588 if (arr[1]->HRegisterToHook(H_HOOK_INIT, #'InitHookCallback,
589 H_HOOK_LIBPRIO(1), H_LISTENER,
590 0) <= 0)
Zesstra658871d2019-07-04 21:34:02 +0200591 {
592 // von allen H_HOOK_INIT wieder abmelden...
593 unsubscribe_init();
594 return -1;
595 }
Zesstra179db0d2016-11-26 13:13:41 +0100596 }
597 }
Zesstra658871d2019-07-04 21:34:02 +0200598 return 1;
Zesstra179db0d2016-11-26 13:13:41 +0100599}
600
601// unsubscribes from all the H_HOOK_INIT.
602private void unsubscribe_init()
603{
604 foreach(mixed* arr : route)
605 {
606 if (arr[0] == HP_ROOM)
607 arr[1]->HUnregisterFromHook(H_HOOK_INIT, #'InitHookCallback);
608 }
609}
610
611private int maybe_pause()
612{
Zesstra7842b8e2019-07-04 21:55:39 +0200613 // we check for time of last player contact. If we did not meet any players
614 // for 2 round-trips, we try to pause.
615 if (meet_last_player < time() - (2*route_time) )
Zesstra179db0d2016-11-26 13:13:41 +0100616 {
Zesstra677b5722019-07-04 22:10:01 +0200617 // we don't stop if players are currently at one of our stops
618 foreach(mixed* arr : route)
619 {
620 if (arr[0] == HP_ROOM)
621 {
622 object room = find_object(arr[1]);
623 if(room &&
624 sizeof(filter(all_inventory(room), #'interactive)))
625 return 0; // no pause
626 }
627 }
628 // and we don't stop if players currently are in the transporter.
629 if (sizeof(filter(all_inventory(this_object()), #'interactive)))
630 return 0;
631 // ok, pause machen
632 return Pause();
Zesstra179db0d2016-11-26 13:13:41 +0100633 }
634 return 0;
635}
636
MG Mud User88f12472016-06-24 23:31:02 +0200637void changeHp()
638{
Zesstrafffd2a82017-10-24 22:03:27 +0200639 // Nicht am Ende der Route? Eins weiter.
640 if (rpos < sizeof(route) - 1)
641 ++rpos;
642 else
MG Mud User88f12472016-06-24 23:31:02 +0200643 {
Zesstra019987a2017-10-24 22:36:08 +0200644 // Routenende
645 // Nach einem expliziten Continue() ist meet_last_player < 0. Dann wird
646 // nicht geprueft, ob wir sofort wieder anhalten. Auch muss dann die Route
647 // nicht uebermittelt werden (hat Start() schon gemacht).
648 if (meet_last_player >= 0)
649 {
650 // TRAVELD die aktuelle Route uebermitteln
651 ReportRoute();
652 // everytime, we pass the end of our route, we check if we should
653 // pause our service.
654 if (maybe_pause())
655 return;
656 }
657 else
658 // Wieder pruefen im naechsten Durchlauf.
659 meet_last_player=abs(meet_last_player);
660
Zesstrafffd2a82017-10-24 22:03:27 +0200661 // wenn keine Pause, wieder zum Anfang der Route bewegen.
662 rpos = 0;
MG Mud User88f12472016-06-24 23:31:02 +0200663 }
Zesstrafffd2a82017-10-24 22:03:27 +0200664
MG Mud User88f12472016-06-24 23:31:02 +0200665 if (route[rpos][0] == HP_MSG)
666 {
667 call_out("changeHp",route[rpos][2]);
668 tell_room(this_object(),route[rpos][1]);
669 }
670 else if (route[rpos][0] == HP_FUN)
671 {
672 call_out("changeHp",route[rpos][2]);
673 call_other(this_object(),route[rpos][1]);
674 }
675 else
676 {
677 call_out("disconnect",route[rpos][2],1,route[rpos][3]);
678 connect(route[rpos][1],route[rpos][4]);
679 }
680}
681