Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Raudhrskal

Pages: [1]
1
Dead Souls Support / Door that destroys keys.
« on: September 21, 2008, 05:46:46 am »
For Aerlindir @ i3.

Side note:
Quote
Raudhrskal <ds> Well, with locks there is a stupid thing. In case of things that inherit LIB_LOCK, (containers, etc.), you can have an callback in key file. But doors/enters don't do it ;( It's an inconsistency, and probably should be fixed.
Code: [Select]
#include <lib.h>

inherit LIB_DOOR;

static void create() {
    door::create();

    SetSide("north", ([ "id" : ({"door leading north", "door", "north door"}),
        "short" : "a door leading north",
        "long" : "This is the south side of a door leading north.",
        "lockable" : 1 ]) );

    SetSide("south", ([ "id" : ({"door leading south", "door", "south door"}),
        "short" : "a door leading south",
        "long" : "This is the north side of a door leading south.",
        "lockable" : 1 ]) );

    SetClosed(1);
    SetLocked(1);

    //If you don't know, strings like "key to north side" are added in 'modify my_key id'
    SetKeys("north", ({ "key to north side" }));
    SetKeys("south", ({ "key to south side" }));
}

//You add THIS:
mixed eventUnlock(object who, object key)
  {
    if(GetLocked()) //if the door is unlocked, we just fall back to parent.
      {
      if(::eventUnlock(who,key)) //Handled?
  {
    if(!GetLocked()) //did the key unlocked the door?
      {
key->eventDestruct(); //kill it.
who->eventPrint("Your key crumbles to dust..."); //message ;)
      }
    return 1; // ::eventUnlock() returned 1, so must we.
  }
return 0;  // ::eventUnlock() returned 0, so must we.
      }
    return ::eventUnlock(who,key);  // Fall back to parent.
  }


void init(){
    ::init();
}
Tested.
'Skal

//EDIT - changed title.

2
For Aerlindir @ i3.
Code: [Select]
#include <lib.h>

inherit LIB_ROOM;

// This function is manually added. If you changed the name of orcish language, type it instead of Tangetto.
string TextInOrcish() {
  return translate("Your text here.",
     this_player() ? this_player()->GetLanguageLevel("Tangetto") : 100);
}

static void create() {
    room::create();
    SetClimate("indoors");
    SetAmbientLight(30);
    SetShort("copy of sample_room.c");
    SetLong("This is a room you can use as a template.");
    SetItems(([
       //added by 'modify here items', 'wall', 'walls', '.', text
       ({ "wall", "walls" }) : "There's something written on the south wall.",
       //added by 'modify here items', 'south wall', '.', text
       ({ "south wall" }) : "There's an inscription on it.",
]));
    SetRead(([
       //added by 'modify here read', 'south wall', '.', text, manually replaced text with (: functional :)
      ({ "south wall" }) : (: TextInOrcish :),
       ]));
    SetExits( ([
"north" : "/realms/raudhrskal/area/room/sample_room",
"east" : "/realms/raudhrskal/area/room/other_room.c",
]) );
    SetInventory(([
   ]));

}

void init(){
    ::init();
}

Works for me.
'Skal

3
Dead Souls Support / Configurable prepositions for furniture
« on: August 29, 2008, 02:04:49 pm »
Kelton at i3 wants to have a piece of furniture to "sit in".

This is a stub of code allowing to make it work.

Code: [Select]
--- ds-dist/lib/lib/lvs/position.c 2008-06-01 21:25:34.000000000 +0200
+++ ds/lib/lib/lvs/position.c 2008-08-29 21:00:44.736593528 +0200
@@ -151,7 +151,7 @@
         }
         return 1;
     }
-    send_messages("sit", "$agent_name $agent_verb down on " +
+    send_messages("sit", "$agent_name $agent_verb down "+target->GetPreposition()+" " +
       target->GetShort() + ".", this_object(), 0, environment());
     Position = POSITION_SITTING;
     Chair = target;
--- ds-dist/lib/lib/events/sit.c 2008-07-07 20:00:36.000000000 +0200
+++ ds/lib/lib/events/sit.c 2008-08-29 20:40:45.303935008 +0200
@@ -10,6 +10,7 @@
 
 private int          MaxSitters = 1;
 private object array Sitters    = ({});
+private string preposition = "on";
 
 int GetMaxSitters(){
     return MaxSitters;
@@ -23,6 +24,17 @@
     return copy(Sitters);
 }
 
+string GetPreposition()
+  {
+    return preposition;
+  }
+
+string SetPreposition(string nw)
+  {
+    if(strlen(nw)) preposition = nw;
+    return preposition;
+  }
+
 mixed eventReceiveSit(object who){
     mixed furn = who->GetProperty("furniture");
     if(furn && objectp(furn)){
@@ -30,7 +42,7 @@
         return 1;
     }
     Sitters = ({ Sitters..., who });
-    who->SetProperty("furniture", " on "+this_object()->GetShort());
+    who->SetProperty("furniture", " "+preposition+" "+this_object()->GetShort());
     who->SetProperty("furniture_object", this_object());
     return 1;
 }
Now just put SetPreposition("in"); (or whatever you want) into your create().

Of course, the same pattern is used on other verbs. Lie, kneel... Will add it later, it's just a ad-hoc piece of code.
Think of it as a demo version having support for only one verb ;).

Regards,
'Skal

4
Open Chat / "Guest"s on forum
« on: July 13, 2008, 10:10:07 am »
Lately, each time I look at forum the statistics box tells me that we've got about 10-15 "guests" online. And details show that they're reading *everything* that's posted on forum.

Wonder if they're Google bots, or something more suspicious...

EDIT: Some of them show up as "Printing topic: <some_topic>". Random link-following bots for sure. Crat, if you could check their IPs, just to be safe...

5
Ok, maybe it's not a bug, but a feature.

But it breaks a lot of things.

Try for example
Code: [Select]
eval return strip_colours("%^GREEN%^BOLD%^x%^RESET%^") // "x"
eval return strlen(strip_colours("%^GREEN%^BOLD%^x%^RESET%^")) //16!
eval return center("%^GREEN%^BOLD%^x%^RESET%^",20) // "  x  ", two spaces on each end
eval return strlen(center("%^GREEN%^BOLD%^x%^RESET%^",20)) //yep, 20
Results are dependent on terminal setting. In case of ansi, the difference is 15 bytes. Unknown may reduce it to 2-3.

How it can be?
Do this. Do NOT use a loop!:
Code: [Select]
eval return convert_ascii(strip_colours("%^GREEN%^BOLD%^x%^RESET%^")[0]) // "x" //ok.
eval return convert_ascii(strip_colours("%^GREEN%^BOLD%^x%^RESET%^")[1]) // " //single "? wtf?
eval return convert_ascii(strip_colours("%^GREEN%^BOLD%^x%^RESET%^")[2]) // "["
eval return convert_ascii(strip_colours("%^GREEN%^BOLD%^x%^RESET%^")[3]) // "4"
eval return convert_ascii(strip_colours("%^GREEN%^BOLD%^x%^RESET%^")[4]) // "9"
And if you continue, you'll see that your "x" has an invisible escape sequence appended to it.

In case of ansi this is <escape>[49;49m<escape>[0;10m - because of the escapes, the second doublequote is swallowed.
In case of unknown it is version-dependent - "current" FluffOS appends same sequence, older used two high-ascii characters - 255 and 239.

This obviously breaks things that use strip_colo(u)rs to obtain "visible" string length. Simplest example - center().

fluffos/packages/contrib.c , functions f_terminal_colour and f_terminal_color.
Look for places where local variables "resetstr", "resetstrname" and "resetstrlen" are used.

I know C, but I'm not familiar with driver's API. Can someone competent tell me why this code has been added? It didn't existed in MudOS' version of this function.

And, of course, how to fix (or work around) it? Currently I am using an LPC-overloaded version of terminal_colour that strips the reset sequence. But this is a major performace penalty.

DS2.7a27 + FluffOS 2.11-ds03 , and some previous versions of course.

6
Dead Souls Support / Better(?) newbie handling
« on: December 20, 2007, 04:11:40 am »
In response to discussion at http://lpmuds.net/forum/index.php?topic=546.0

In FAQ, Cratylus recommends setting MAX_NEWBIE_LEVEL to 0 for disabling the newbies'
bonuses. This renders newbiep() sefun and some tools (like -n option to people)
useless. Better would be to have separately configured newbie options, while
allowing the MAX_NEWBIE_LEVEL to stay > 0.

I'd hacked the following. (Yes, I know, the keywords are poorly chosen...
just can't invite anything better ;( )

Stock DS 2.6

Code: [Select]
--- secure/save/backup/config.1197038311        2007-12-07 15:38:32.000000000 +0100
+++ secure/include/config.h     2007-12-18 00:08:36.000000000 +0100
@@ -32,6 +32,11 @@
 #define SUPPORTED_CLIENTS       ({ "amcp", "amcp/1.1" })
 #define HOUR_LENGTH              1200
 #define DAY_LENGTH               20
+#define NEWBIE_CLEARVISION       0
+#define NEWBIE_POLYGLOT          0
+#define NEWBIE_NO_MONEY_DROP     0
+#define NEWBIE_SKILL_PROTECT     1
+#define NEWBIE_NO_HEAVY_WEAPONS  1
 #define MAX_NEWBIE_LEVEL         3
 #define AUTOSAVE_TIME            450
 #define MORTAL_POSITIONS         ({ "player", "high mortal", "ambassador" })
Code: [Select]
--- secure/cmds/admins/mudconfig.c~     2007-11-06 02:18:00.000000000 +0100
+++ secure/cmds/admins/mudconfig.c      2007-12-18 00:07:43.000000000 +0100
@@ -15,12 +15,14 @@
 string array restrict_tokens = ({ "restrict","unrestrict" });
 string array nonmodals = ({ "liveupgrade", "prompt","status","email","websource",
   "debugger", "access", "pinging", "pinginterval" });
-string array antimodals = ({ "imc2" });
+string array antimodals = ({ "imc2" /*rwd(*/, "nooballweapons", "noobcashdrop" /*rwd)*/ });
 string array modals = antimodals + ({ "catchtell","matchcommand", "matchobject", "autowiz", "locked",
   "localtime", "justenglish", "justhumans", "encumbrance", "pk", "compat", "exitsbare", "nmexits",
-  "retain", "defaultparse", "disablereboot", "loglocal", "logremote" });
+  "retain", "defaultparse", "disablereboot", "loglocal", "logremote"
+  /*rwd(*/, "noobskillprot", "noobvision", "nooblangs" /*rwd)*/ });
 string array inet_services = ({ "oob", "hftp", "ftp", "http", "rcp", "inet" });

+
 static int NotImplemented(string which);
 varargs static int TestFun(string which, string arg);
 varargs static int ModIntermud(string which, string arg);
@@ -448,6 +450,13 @@
     case "loglocal" : which = "LOG_LOCAL_CHANS";break;
     case "logremote" : which = "LOG_REMOTE_CHANS";break;
     case "imc2" : which = "DISABLE_IMC2";break;
+      //rwd(
+      case "noobvision" : which = "NEWBIE_CLEARVISION";break;
+      case "nooblangs" : which = "NEWBIE_POLYGLOT";break;
+      case "noobcashdrop" : which = "NEWBIE_NO_MONEY_DROP";break;
+      case "noobskillprot" : which = "NEWBIE_SKILL_PROTECT";break;
+      case "nooballweapons" : which = "NEWBIE_NO_HEAVY_WEAPONS";break;
+      //rwd)
     default : break;
     }
     foreach(string element in config){
@@ -465,6 +474,10 @@
     }
     CompleteConfig();
     if(which == "DEFAULT_PARSING" || which == "ENABLE_ENCUMBRANCE" ||
+       //rwd(
+       which == "NEWBIE_CLEARVISION" || which == "NEWBIE_POLYGLOT" ||
+       which == "NEWBIE_SKILL_PROTECT" ||
+       //rwd)
       which == "BARE_EXITS" || which == "COMMAND_MATCHING"){
         reload(LIB_CREATOR,1,1);
         write("This configuration will take effect for each user the next time they log in.");
@@ -493,7 +506,27 @@
         else IMC2_D->remove();
         reload(CHAT_D);
     }
-
+    //rwd(
+    if(which == "NEWBIE_NO_MONEY_DROP")
+       {
+           if(file_exists("/verbs/items/give.c"))
+               reload("/verbs/items/give.c");
+           if(file_exists("/verbs/items/drop.c"))
+               reload("/verbs/items/drop.c");
+           if(file_exists("/verbs/items/put.c"))
+               reload("/verbs/items/put.c");
+           reload("/daemon/verbs.c");
+           return 1;
+       }
+    if(which == "NEWBIE_NO_HEAVY_WEAPONS")
+       {
+           reload("/lib/comp/weapon.c");
+           write("This configuration will take effect for weapons not yet loaded. "
+                 "To ensure all weapons pick up the new configuration, either reboot "
+                 "the mud, or type: \"reload every weapon\".");
+           return 1;
+       }
+    //rwd)
     return 1;
 }

@@ -720,6 +753,13 @@
       "\nmudconfig matchcommand [ yes | no ]"
       "\nmudconfig matchobject [ yes | no ]"
       "\nmudconfig exitsbare [ yes | no ]"
+      //rwd(
+      "\nmudconfig noobvision [ yes | no ]"
+      "\nmudconfig nooblangs [ yes | no ]"
+      "\nmudconfig noobcashdrop [ yes | no ]"
+      "\nmudconfig noobskillprot [ yes | no ]"
+      "\nmudconfig nooballweapons [ yes | no ]"
+      //rwd)
       "\nmudconfig nmexits [ yes | no ] (This togggles where default exits are displayed)"
       "\nmudconfig localtime [ yes | no ]"
       "\nmudconfig offset <offset from gmt in seconds>"
Code: [Select]
--- lib/player.c~       2007-11-08 20:46:56.000000000 +0100
+++ lib/player.c        2007-12-17 23:45:14.000000000 +0100
@@ -200,7 +200,7 @@
         if( !random(4) ) {
             continue;
         }
-        if( newbiep(this_object()) ) {
+        if( NEWBIE_SKILL_PROTECT && newbiep(this_object()) ) {
             x = 2;
         }
         else {
@@ -800,7 +800,7 @@
 }

 varargs mixed GetEffectiveVision(mixed location, int raw_score) {
-    if( newbiep(this_object()) ) return VISION_CLEAR;
+    if( NEWBIE_CLEARVISION && newbiep(this_object()) ) return VISION_CLEAR;
     else if(raw_score && location) return living::GetEffectiveVision(location,raw_score);
     else if(location) return living::GetEffectiveVision(location);
     else return living::GetEffectiveVision();
@@ -818,7 +818,7 @@
 }

 int GetLanguageLevel(string lang) {
-    if( newbiep() ) return 100;
+    if( NEWBIE_POLYGLOT && newbiep() ) return 100;
     else return living::GetLanguageLevel(lang);
 }

Code: [Select]
--- lib/comp/weapon.c~  2007-11-08 20:46:56.000000000 +0100
+++ lib/comp/weapon.c   2007-12-17 22:55:11.000000000 +0100
@@ -111,7 +111,7 @@
     if( Hands > sizeof(who->GetWieldingLimbs()) ) {
         return "#You do not have enough limbs for that weapon!";
     }
-    if( newbiep(who) && GetClass() > 30 ) {
+    if( NEWBIE_NO_HEAVY_WEAPONS && newbiep(who) && GetClass() > 30 ) {
         return "You are not skilled enough to wield this weapon.";
     }
     return 1;
Code: [Select]
--- lib/talk.c~ 2007-10-31 06:15:42.000000000 +0100
+++ lib/talk.c 2007-12-17 22:25:59.000000000 +0100
@@ -106,7 +106,7 @@
     if(riders && sizeof(riders))
         riders->eventHearTalk(who, target, cls, verb, (msg ||0), (lang ||0));
 
-    if( lang && !newbiep() && !GetPolyglot() ) msg = translate(msg, GetLanguageLevel(lang));
+    if( lang && ( !NEWBIE_POLYGLOT || !newbiep() ) && !GetPolyglot() ) msg = translate(msg, GetLanguageLevel(lang));
     switch(cls) {
     case TALK_PRIVATE:
         if( target != this_object() ) return 0;
Code: [Select]
--- verbs/items/give.c~ 2007-12-05 21:42:18.000000000 +0100
+++ verbs/items/give.c  2007-12-17 22:59:02.000000000 +0100
@@ -63,7 +63,7 @@
     if( amt < 1 ) return "What sort of amount is that?";
     if( amt > (int)this_player()->GetCurrency(lower_case(curr)) )
         return "You don't have that much " + curr + ".";
-    if(this_player()->GetLevel() < 4) return "Newbies can't give money.";
+    if(NEWBIE_NO_MONEY_DROP && newbiep(this_player())) return "Newbies can't give money.";
     return this_player()->CanManipulate();
 }

Code: [Select]
--- verbs/items/drop.c~ 2007-12-05 21:42:18.000000000 +0100
+++ verbs/items/drop.c  2007-12-17 22:59:32.000000000 +0100
@@ -47,7 +47,7 @@
     if( (amt = to_int(num)) < 1 ) return "You cannot do that!";
     if( (int)this_player()->GetCurrency(curr) < amt )
         return "You don't have that much " + curr + ".";
-    if(this_player()->GetLevel() < 4) return "Newbies can't drop money.";
+    if(NEWBIE_NO_MONEY_DROP && newbiep(this_player())) return "Newbies can't drop money.";
     return this_player()->CanManipulate();
 }

Code: [Select]
--- verbs/items/put.c~  2007-12-05 21:42:18.000000000 +0100
+++ verbs/items/put.c   2007-12-17 23:00:27.000000000 +0100
@@ -68,10 +68,7 @@
     if( (amt = to_int(num)) < 1 ) return "You cannot do that!";
     if( (int)this_player()->GetCurrency(curr) < amt )
         return "You don't have that much " + curr + ".";
-    if(this_player()->GetLevel() < 4) {
-        write("Newbies cannot drop money.");
-        return "Newbies can't drop money.";
-    }
+    if(NEWBIE_NO_MONEY_DROP && newbiep(this_player()))  return "Newbies can't drop money.";
     if(wrd == "on" || wrd == "onto"){
         if(container && !inherits( LIB_SURFACE, container ) ) return "#That isn't a load-bearing surface.";
     }

All newbie bonuses I've found are now easily customizable, and I still have people -n working ;)

One more question: Should I send less verbose messages afterwards?

Wesolych Swiat / Merry Christmas,
'Skal

7
Dead Souls Support / Object matching and entry messages
« on: November 12, 2007, 12:47:51 am »
We've got a small bug^H^H^H old optimization here. It conflicts with OBJECT_MATCHING.

Code: [Select]
> goto /domains/campus/room/basement
The basement
You are in the basement of the LPC University administrative building. It is very dark here, and rather damp. The fluorescent
lighting seems to be on the verge of total failure, with only one or two flickering on and off enough to see anything. The air
here is damp, thick and musty. There is a small crawlspace you can enter under the stairs here, and the basement continues east
into darkness.
Obvious exits: east, up, enter crawlspace
A rat is standing here.
>
Now, to load the room and allow rat to wander:
Code: [Select]
> enter crawlspace
/domains/campus/room/crawlspace
A tiny crawlspace
You are in a cramped little space beneath the stairs in the basement. It is dark, tight, and dirty in here.
Obvious exit: out
A small, plastic flashlight and thirty-one dollars are here.
> out
/domains/campus/room/basement
The basement
You are in the basement of the LPC University administrative building. It is very dark here, and rather damp. The fluorescent
lighting seems to be on the verge of total failure, with only one or two flickering on and off enough to see anything. The air
here is damp, thick and musty. There is a small crawlspace you can enter under the stairs here, and the basement continues east
into darkness.
Obvious exits: east, up, enter crawlspace
>
(wait a moment...)
Code: [Select]
A mangy little rat scurries in.
A mangy little rat enters into the cr.
A mangy little rat scurries in.
A mangy little rat enters into the crawl.
A mangy little rat scurries in.
A mangy little rat enters into the crawlsp.
A mangy little rat scurries in.
A mangy little rat enters into the craw.
A mangy little rat scurries in.
A mangy little rat enters into the crawlspac.
A mangy little rat scurries in.
A mangy little rat enters into the crawlspace.
A mangy little rat scurries in.
A mangy little rat enters into the crawlspa.
A mangy little rat scurries in.
A mangy little rat enters into the crawlspace.

After half a minute (thanks again for findfun command), I've found this:
Code: [Select]
/lib/sentient.c:
293: foreach(tmp in (string *)environment()->GetEnters()) {
And, of course:
Code: [Select]
> call here->GetEnters()
OBJ(/domains/campus/room/basement) -> GetEnters() = ({ "crawlspace", "crawlspac", "crawlspa", "crawlsp", "crawls", "crawl",
"craw", "cra", "cr", "/lib/std/dummy#27", "crawlspace", "crawlspace", "crawlspac", "crawlspa", "crawlsp", "crawls", "crawl",
"craw", "cra", "cr" })
>
Why?
Code: [Select]
/lib/exits.c:
177: varargs string array GetEnters(int i) {
(snip...)
190:     foreach(object ob in obs) {
191:         if( ob->GetEnter() ) {
192:             if(i) ids += ({ ob->GetId()[0] });
193:             else ids += ob->GetId();
193:         }
195:     }
Code: [Select]
/lib/props/id.c:
57: string array GetId() {
58:     string tmp;
59:     //if(!inherits(LIB_GERM,this_object())) tmp = GetKeyName();
60:     tmp = GetKeyName();
61:
62:     if( tmp ) {
63:         if(!OBJECT_MATCHING || !Matching) return distinct_array(({ CanonicalId..., tmp }));
64:         else return Id + ({ file_name(this_object()) }) + atomize_string(tmp) - ExcludedIds;
65:     }
66:     else return Id;
67: }

Ok, so if I change line 293 in /lib/sentient.c from GetEnters() to GetEnters(1) wandering monsters will not
use truncated names. (This is good because the wandering code picks an entrance randomly, and now it is
imbalanced - crawlspace with truncations has 20 entries in array, while for example 'hut' will have... er...
(@#%$ duplicates)... 3? 6? Not the same amount, that is. With GetEnters(1) every entrance has one array entry.)

But what if player types 'enter crawlsp' instead of 'enter crawlspace'?
Code: [Select]
Raudhrskal enters into the crawlsp.Oops.

Let's see... verb just call eventEnter...
Code: [Select]
/lib/enter.c:
95:  varargs mixed eventEnter(object who, string what, string verb) {
(snip)//string what is the word as typed by player^^^ - it worked in the old days where the full name was required
114:     if(verb == "crawl") who->eventMoveLiving(Enter["room"],"into the " + what );
115:     else who->eventMoveLiving(Enter["room"], "$N enters into the " + what + ".");
Aha!

My current fix (in addition to the sentient.c:293) is:
Code: [Select]
--- lib/enter.c~        2007-10-27 21:45:03.000000000 +0200
+++ lib/enter.c 2007-11-11 18:42:51.769447000 +0100
@@ -111,8 +111,8 @@
     if( Enter["pre"] && !evaluate(Enter["pre"], what) ) {
         return 1;
     }
-    if(verb == "crawl") who->eventMoveLiving(Enter["room"],"into the " + what );
-    else who->eventMoveLiving(Enter["room"], "$N enters into the " + what + ".");
+    if(verb == "crawl") who->eventMoveLiving(Enter["room"],"into the " + this_object()->GetKeyName() );
+    else who->eventMoveLiving(Enter["room"], "$N enters into the " + this_object()->GetKeyName() + ".");
+    //this_object() refers to the dummy entrance item                          ^^^
     if( Enter["post"] ) {
         evaluate(Enter["post"], what);
     }
This is a Kludge(tm). /lib/enter is inherited by the dummy entrance, but it may be inherited by somthing else.
'grep -R LIB_ENTER /*' reveals /lib/vehicle.c - this is OK, it has GetKeyName(). But there must be a better way to fix this.
Any ideas?

'Skal

PS. Exits are unaffected by the matching system - they are not dummy objects.
Code: [Select]
OBJ(/domains/campus/room/basement) -> GetExits() = ({ "east", "up" })PPS. I use the basement as an example - tested also with the dry well.
PPPS. This is DS 2.5a21 - if it has been fixed last week, sorry.

8
Dead Souls Support / Better Unix start script...
« on: May 22, 2007, 01:59:31 am »
Well, I wanted to contribute this little thing that I'm using since 2005.
STILL 100% (d)(a)sh compatible, of course works also with bash and zsh's sh emulation.
Allow to conditionally exit the loop.

If you add somthing like "exec 2>&1 > /some/file" at the beginning, it should redirect all output to file, but I didn't tested that.

Code: [Select]
#!/bin/sh
#For ability to shutdown the mud, change line in /secure/cmds/admins/shutdown.c
#from:          call_out( (: shutdown :), 1);
#to:            call_out( (: shutdown :), 1, -1);
#and, if you want (afaik void ShutDown() isn't called anywhere but...)
#from           shutdown();
#to             shutdown(-1);
#and after updating command file and /daemon/command end will reboot (as usual)
#and shutdown will shutdown. If you want to use the 'shutdown' command
#for rebooting, you can add some parameter check, or simply copy shutdown.c
#to e.g. haltmud.c and change the call_out there.

#NOTE: To interrupt the while loop in script you may need to hold Ctrl-C for a moment
#      (first MudOS will be killed, and next the script - if you'll be still holding the key)
#      This will leave addr_server running in the background
#      just do     killall addr_server      or       kill `pidof addr_server`

# Specify your mud dir here.
MUDHOME="/opt/ds";

#Original author said:
# It has been reported that non-US users have problems
# with some .o files because their systems default to
# commas for decimal notation and not periods. The
# following language exports are for the benefit of
# people who run into this problem.

#LANG=en_US;
#LANGUAGE=en_US;
#LC_ALL=en_US;

#That's true. I had this problem too. But it should be
LANG=C;
LANGUAGE=C;
LC_ALL=C;
#C is the 'standard' locale. Right, the 'en_US' will still work,
#because if your system don't have specfic locale data for en_US
#it will automatically fall back to C. But what if system HAS
#some weird locale data for en_US? (some older HP-UX, for example)

export LANG LANGUAGE LC_ALL MUDHOME;

umask 007;

ulimit -n 1024;

echo "$0: `date`: Job starting...";

if [ $MUDHOME ] && [ -x $MUDHOME/bin/addr_server ];
        then #Run it in background
echo "$0: `date`: Running addr_server...";
        $MUDHOME/bin/addr_server 8099 & #change port if you need to - 8099 is in 2.3a1, older used 9999
addrpid=$!; #Catch the process ID
echo "$0: `date`: addr_server PID is" $addrpid;
fi

count=1; #boot count
retv=0;  #./driver return value

echo "$0: `date`: Entering loop.";

#Choose one option:
while [ $retv = "0" ]; do #continue ONLY if the driver exited gracefully - not by signal, not by efun shutdown(-1)
#while [ $retv != "255" ]; do #continue ALWAYS, even if the driver exited by signal, halt ONLY after efun shutdown(-1)

    echo "$0: `date`: Boot count:" $count;

    if [ $MUDHOME ] && [ -x $MUDHOME/bin/driver ]  && [ -f $MUDHOME/bin/mudos.cfg ];
    then
    $MUDHOME/bin/driver $MUDHOME/bin/mudos.cfg;
    retv=$?; #catch the return value
    echo "$0: `date`: Driver exit. Code" $retv;
    elif [ -x ./driver ]  && [ -f ./mudos.cfg ];
    then
    ./driver ./mudos.cfg;
    retv=$?; #catch the return value
    echo "$0: `date`: Driver exit. Code" $retv;
    else
    retv=255; #exit
    echo "$0: `date`: Can't find driver and/or mudos.cfg!";
    break;
    fi;
    count=$(($count+1));
    sleep 5; #this won't hurt, and sometimes even helps
done

echo "$0: `date`: Exiting loop.";

if [ $addrpid ]; #We started it?
then
echo "$0: `date`: Killing addr_server...";
kill $addrpid;
fi

echo "$0: `date`: End of job.";

Pages: [1]