1
Code Vault / Re: sefun WrapText()
« on: November 02, 2011, 04:08:09 pm »
And instead of setting tab to 4 or 5 spaces, put a nice TAB variable at the top and let folks set their own

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.
int d;
string b;
string fun;
string *funs;
string *sdi=get_dir("/doc/sefun/");
string *edi=get_dir("/doc/efun/all/");
string *ldi=get_dir("/doc/lfun/all/");
string fi=read_file("/secure/sefun/sefun.h");
funs=explode(fi, "\n");
foreach(fun in funs){
if(strsrch(fun, ";") != -1 && strsrch(fun, "//")==-1){
b=fun[0..strsrch(fun,"(")-1];
b=b[strsrch(b, "",-1)+1..];
sscanf(b, "*%s",b);
}
if(member_array(b, sdi) == -1 && member_array(b, edi) == -1 && member_array(b, ldi) == -1){
write(b);d++;
}
}
write("Total: "+d);
Player Login flowpath
NEW PLAYER PATH
Driver calls connect() in master.c
/secure/daemon/master.c
object connect(int port)
Driver calls logon() in object returned by connect call
/secure/lib/connect.c
varargs static void logon(mixed foo)
static void InputName(string namen, string kill_me)
static void eventCreatePlayer(string cap)
static void ConfirmName(string ans, string cap)
static void AgeCheck(string ans, string cap)
static void CreatePassword(string pass, string cap)
static void ConfirmPassword(string control, string cap, string pass)
static void InputGender(string str, string cap)
static void InputCapName(string name, string cap)
static void InputEmail(string email)
static void InputRealName(string rname)
static void InputRace(string str)
static void cmdPick(string args)
void eventCompleteChar()
Player->SetRace(raza)
Player->SetProperty("brand_spanking_new",1)
Player->AddCurrency("silver",random(100)+57)
Player->SetRace(raza)
Player->SetPassword(Passwort)
Player->SetGender(Gendre)
Player->SetCapName(CapNamen)
Player->SetEmail(E_Mail)
Player->SetRealName(TrueName)
Player->SetLanguage("Common",100)
Player->SetDefaultLanguage("Common")
this_player()->SetWimpy(20)
this_player()->SetTerminal("ansi")
PLAYERS_D->AddPlayerInfo(Name)
static private void eventEnterGame()
/******************************************************************************
File: room.h
Desc: Headers, bit, and flag settings for rooms.
******************************************************************************/
// Room bit inheritable
// The room_bits object has all room specific bit and flag settings.
#define ROOM_BITS "/lib/room/room_bits"
// These are toggled bits for each room. Usage is:
// void RoomBits_SetBit(int bit); // set a bit
// void RoomBits_ClearBit(int bit); // clear a bit
// int RoomBits_TestBit(int bit); // test if a bit is set
#define ROOM_BIT_SAFE_ROOM 0 // Room is safe: no combat, no spells
#define ROOM_BIT_INDOORS 1 // (unused)
#define ROOM_BIT_NOMOB 2 // NPC's cannot enter
#define ROOM_BIT_TUNNEL 3 // Only one player in room at a time
#define ROOM_BIT_NOSMELL 4 // Scents are not left in the room
#define ROOM_BIT_NOPRINTS 5 // No prints are left in the room
#define ROOM_BIT_NOTRACK 6 // Nothing can be tracked
#define ROOM_BIT_PRIVATE 7 // Can't teleport/trans into room
#define ROOM_BIT_NO_ATTACK 8 // Room is no attack
#define ROOM_BIT_NO_MAGIC 9 // Room is no magic
#define ROOM_BIT_NO_STEAL 10 // Room is no steal
#define ROOM_BIT_NO_SUMMON 11 // Room is no summon
#define ROOM_BIT_NO_TELEPORT 12 // Room is no teleport
#define ROOM_BIT_NO_SCRY 13 // Room is no scry
#define ROOM_BIT_SOUNDPROOF 14 // Room is cut off from lines, tells
#define ROOM_BIT_DEATH 15 // Player dies if they enter
#define ROOM_BIT_NO_AIR 16 // Gasp! Need air to breathe!
/********************************************************************
File: room_bits.c
Written By: Nevin
Desc: File to control room bit and flag settings in one location.
Much cleaner than before and provides for a standard method of
setting information for rooms.
********************************************************************/
#include <room.h>
string roomBits = ""; // room bit string var
/********************************************************************
Room Bit Code
********************************************************************/
// Sets a room bit
void RoomBits_SetBit(int bit)
{
roomBits = set_bit(roomBits, bit);
}
// Clears a room bit
void RoomBits_ClearBit(int bit)
{
roomBits = clear_bit(roomBits, bit);
}
// Tests a room bit
int RoomBits_TestBit(int bit)
{
return test_bit(roomBits, bit);
}
// Census tool.
#include <dirs.h>
int totusers();
int pending() {if(event_pending(this_object())) return 1;return 0;}
int nexttot() {add_event(base_name(this_object()), base_name(this_object()), "totusers", ({}), 300, 1);return 1;}
int lastran, lastday, maxday, halfmax;
int *daily;
int *monthly;
string *names,*newbie, *oldnames, *oldnewbie;
int forever;
void login(string name);
void newuser(string name);
int *query_daily() {return daily;}
int *query_monthly() {return monthly;}
int query_forever() {return forever;}
int query_maxday();
string *query_names() {return oldnames;}
string *query_newbie() {return oldnewbie;}
int query_maxday() {
int *a,b,c,d;
a=query_daily();
for(b=0,c=sizeof(a);b<c;b++) {
if(a[b]==0) continue;
if(a[b] > d)
d=a[b];
}
return d;
}
string query_lastran() {return ("lastran "+ctime(lastran)+"lastday "+ctime(lastday));}
void create() {
if(!event_pending(this_object())) {
add_event(base_name(this_object()), base_name(this_object()), "totusers", ({}), 300, 1);
}
names=({});
newbie=({});
oldnames=({});
oldnewbie=({});
daily = allocate(48);
monthly = allocate(31);
if(file_exists(DIR_SAVE+"/usage.o"))
restore_object(DIR_SAVE+"/usage");
return;
}
void fix_monthly(){
monthly = allocate(31);
this_object()->update_usage();
return;
}
void login(string name) {
if(!name) return;
if(member_array(name,names) != -1) return;
if(!names) names = ({});
names+=({name});
return;
}
void newbie(string name) {
if(!name) return;
if(member_array(name, newbie) != -1) return;
if(!newbie) newbie = ({});
newbie += ({name});
return;
}
string graph(int a) {
string sym;
switch(a) {
case 20: sym = "%^BOLD%^%^RED%^*";break;
case 16..19: sym = "%^BOLD%^%^WHITE%^*";break;
case 12..15: sym = "%^BOLD%^%^YELLOW%^*";break;
case 8..11: sym = "%^GREEN%^*";break;
case 4..7: sym = "%^CYAN%^*"; break;
case 0..3: sym = "%^BLUE%^*";break;
default: sym = "%^BOLD%^%^WHITE%^^";break;
}
return sym;
}
string display_daily() {
string disp;
int i,j;
disp = "";
i=20;
while(i>0) {
for(j=0;j<24;j++) {
if(daily[j] > 3*i)
disp += graph(i);
else disp += " ";
if(daily[j+24] > 3*i)
disp += graph(i);
else disp += " ";
disp += " ";
}
disp += "\n";
i--;
}
disp += "%^RESET%^";
for(j=0;j<24;j++) {
if(j < 10) disp += "0"+j+" ";
else disp += "" + j + " ";
}
disp +="\n";
return disp;
}
string display_monthly() {
string disp;
int i,j;
disp = "";
i=20;
while(i>0) {
for(j=1;j<31;j++) {
if(monthly[j] > 3*i)
disp += graph(i);
else disp += " ";
disp += " ";
}
disp += "\n";
i--;
}
disp += "%^RESET%^";
return disp;
}
int query_day() {
int day;
sscanf(ctime(time()),"%*s %*s %d %*d:%*d:%*s %*s", day);
return day;
}
varargs void update_usage(int frc) {
int hour, min, day;
sscanf(ctime(time()),"%*s %*s %d %d:%d:%*s %*s", day, hour, min);
if(min > 30 && min < 60 ) hour = hour+24;
if(sizeof(users()) > halfmax) daily[hour]=(int)sizeof(users());
else daily[hour]=halfmax;
maxday = query_maxday();
if(maxday > forever) forever = maxday;
lastran = time();
halfmax = 0;
if( (time() > (lastday + 86400)) || frc) {
monthly[day]=(int)maxday;
maxday = 0;
oldnames = names;
oldnewbie = newbie;
names = ({});
newbie = ({});
lastday = time();
}
save_object(DIR_SAVE+"/usage");
return;
}
int totusers() {
halfmax = sizeof(users());
call_out("nexttot",300);
if(time() > (lastran+1600) ) update_usage();
return 1;
}
/* /cmds/players/census.c
* Made for Dead Souls lib
* Created by Archaegeo
* Do not remove this header
*/
#define USAGE "/daemon/census_d"
mixed cmd(string arg) {
int *a, b, c, d, e, f, g;
string *nm, dys;
if(arg=="m") {
message("info","\n"+USAGE->display_monthly(), this_player());
c=USAGE->query_day();
dys="";
for(b=0;b<31;b++) {
if((b+1)==c) {
if(b<9) dys +="%^YELLOW%^"+(b+1)+" %^RESET%^";
else if(b>8 && b<19) dys +="%^YELLOW%^"+(1)+" %^RESET%^";
else if(b<29) dys +="%^YELLOW%^"+(2)+" %^RESET%^";
else dys +="%^YELLOW%^"+(3)+" %^RESET%^";
}
else {
if(b<9) dys +="%^RESET%^"+(b+1)+" ";
else if(b>8 && b<19) dys +="%^RESET%^"+(1)+" ";
else if(b<29) dys +="%^RESET%^"+(2)+" ";
else dys +="%^RESET%^"+(3)+" ";
}
}
message("info",dys+"\n"
" 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n",this_player());
message("info",
" Daily Highs for Past Month\n", this_player());
}
else if(arg == "n") {
message("info","The following people were online yesterday.",this_player());
nm=USAGE->query_names();
write(format_page(nm, 5) +"\n");
}
else {
message("info","\n"+USAGE->display_daily(), this_player());
message("info",
" Daily Census Chart\n", this_player());
}
a=USAGE->query_monthly();
d=0;
g=0;
for(b=0,c=sizeof(a);b<c;b++) {
if(a[b]==0) continue;
if(a[b] > d) {
d=a[b];
g=b;
}
if(a[b] > 0) e++;
f+=a[b];
}
b=USAGE->query_forever();
write(" New Users Yesterday: "+sizeof((USAGE->query_newbie())));
write(" Unique Logins Yesterday: "+sizeof((USAGE->query_names())));
write(" High in last 24 hours: "+USAGE->query_maxday());
write(" Daily Average: "+(f/e)+"\n High for Month: "+d+" players, "+(USAGE->query_day()-g)+" days ago.");
write(" Highest Recorded Usage: "+b+"\n");
return 1;
}
int help() {
message("help",
"This command is used to see mud usage over the last 24 hour "
"period. You can use this to plan your play time depending "
"if you want to be on at the same time as the most or least "
"folks. Usage: census\n<census m> will display a monthly chart."
"\n<census n> will display all folks who have logged in during past 24 hours.", this_player());
return 1;
}
"/daemon/census_d"->login(Name);
"/daemon/census_d"->newbie(Name);
mapping AllIndices(){
mapping ret;
ret = Indices;
return ret;
}
/* Do not remove the headers from this file! see /USAGE for more info. */
// Modified from Lima 1.05b by Archaegeo on 1/1/08 for Dead Souls Lib
#include <lib.h>
#include <daemons.h>
#define MIN_LEN 3
mixed apropos(string s);
mixed cmd(string s) {
string yt;
if (!s)
{
write("apropos <string>\n\n"
"Returns information on which mudlib functions contain the\n"
"keyword passed, including a short description.\n");
return;
}
if (strlen(s)<MIN_LEN)
{
write("Please find a bigger search criteria (min. "+MIN_LEN+
" letters).\n");
return;
}
yt=apropos(s);
if (yt=="\n")
write("No help files match your word.\n");
this_player()->eventPrint(yt);
return 1;
}
//:COMMAND
//Returns information on which help files contain the
//keyword passed, including a short description.
mixed apropos(string s)
{
mapping filer=([]);
mapping topics;
string output="";
string *st;
string pwd;
topics=HELP_D->AllIndices();
if(!topics)
{
error("Apropos whines about help_d not giving any info out.\n");
return;
}
foreach (string key,string *files in topics)
{
foreach(string d in topics[key]) {
if (strsrch(d,s)!=-1)
{
output += "[" + key + "]: " + d +"\n";
}
}
}
output+="\n";
return output;
}
string GetHelp(string str) {
return ("Syntax: <apropos <name>>\n\n"
"Pages through the help file names that have been indexed for <name>.\n"+
"See also: help index");
}