/* This file allows you to output a list of mud areas to your web page.
Do not remove the copyright statement and link to the Clandestine
page included in the HTML output. */
/* To implement this code, simply make a call to areas_html_update
somewhere in your code. You can execute every time by placing it
in db.c, or you can create a command for it in interp.c and
execute only when you wish. */
/* The replacement of Clandestine-specific terms is left as an
exercise for the user. You will need to change the path to the
file, and modify the text appropriately for your mud. */
/* The specific format required for the pArea->credits variable is:
{## ##} AuthorX Title of area
^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^^
| | starts at 16th character
| starts at 8th character, 7 letter max
left brace, and either low and high level, "ALL", "IMM", "HERO", or other
abbreviations. See the sorted area list snippet for where these are
interpreted. You can, of course, edit these features to match your MUD.
This does require the sorted area list snippet available at
http://clandestine.mudnet.net/code.html
*/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <malloc.h>
#include "merc.h"
#include "recycle.h"
#if !defined(macintosh)
extern int _filbuf args( (FILE *) );
#endif
void under_line(char *under_lined, char *spaced_out )
{
char * point;
#ifdef DEBUG
Debug ("under_line");
#endif
strcpy(under_lined,spaced_out);
for (point = under_lined; *point; point++)
{
if (*point == ' ')
{
*point = '_';
}
else
{
*point = LOWER(*point);
}
}
return;
}
/* Requires sorted area list snippet in db.c which includes this function */
long get_area_level args ((AREA_DATA *pArea));
/* The under_line() function from webspells.c is needed to create
valid HTML links. */
/* And a reverse hack of the under_line() function turns a list
of affects/immunities from "this_affect that_affect the_other_affect"
to "this affect, that affect, the other affect, " */
void un_under_line(char *spaced_out, char *under_lined )
{
char * point;
char * space;
#ifdef DEBUG
Debug ("un_under_line");
#endif
spaced_out[0] = '\0';
space = spaced_out;
for (point = under_lined; *point; point++)
{
/* replace _ with a space */
if (*point == '_')
*space++ = ' ';
else
/* and insert a comma where there already is a space */
if (*point == ' ')
{
*space++ = ',';
*space++ = ' ';
}
else
/* otherwise just copy the character */
{
*space++ = *point;
}
}
/* We'll return with a comma at the end so that multiple lists
can be appended together. Remove after the last one is appended. */
*space++ = ',';
*space++ = ' ';
*space = '\0';
return;
}
void areas_html_update (void)
{
FILE *fp;
AREA_DATA *pArea;
char buf[MAX_INPUT_LENGTH];
char buf2[8];
#ifdef DEBUG
Debug ("areas_html_update");
#endif
buf[0] = '\0';
buf2[0] = '\0';
fclose(fpReserve);
if ( (fp = fopen(WEB_AREA, "w") ) == NULL)
{
bug( "areas.html: fopen", 0 );
perror( "areas.html" );
}
else
{
fprintf(fp, "<html>\n");
fprintf(fp, "<head>\n");
fprintf(fp, "<title>\n");
fprintf(fp, "Areas on Soulblight\n");
fprintf(fp, "</title>\n");
fprintf(fp, "<BODY TEXT=\"#C0C0C0\" BGCOLOR=\"#000000\" LINK=\"#00FFFF\"\n");
fprintf(fp, "VLINK=\"#FFFFFF\" ALINK=\"#008080\" BACKGROUND=\"dragbkgd.gif\">\n");
fprintf(fp, "<h1><center>Areas on Soulblight</center></h1>\n");
fprintf(fp, "<CENTER><TABLE BORDER=1>\n");
fprintf(fp, "<TR ALIGN=CENTER VALIGN=CENTER>\n");
fprintf(fp, "<TD COLSPAN=2>Low/High<br>Level</TD>\n");
fprintf(fp, "<TD>Author</TD>\n");
fprintf(fp, "<TD>Area Name</TD></TR>\n");
for ( pArea = area_first_sorted ; ; )
{
if (pArea == NULL)
break;
fprintf(fp, "<TR ALIGN=CENTER VALIGN=CENTER>\n");
if ((get_area_level(pArea) / (MAX_LEVEL+1) == 0) &&
(get_area_level(pArea) % (MAX_LEVEL+1) == MAX_LEVEL))
{
fprintf(fp, "<TD COLSPAN = 2>ALL</TD>\n");
}
else
if ((get_area_level(pArea) / (MAX_LEVEL+1) == AVATAR) &&
(get_area_level(pArea) % (MAX_LEVEL+1) == MAX_LEVEL))
{
fprintf(fp, "<TD COLSPAN = 2>Religion</TD>\n");
}
else
if ((get_area_level(pArea) / (MAX_LEVEL+1) > AVATAR) &&
(get_area_level(pArea) % (MAX_LEVEL+1) == MAX_LEVEL))
{
fprintf(fp, "<TD COLSPAN = 2>Immortal</TD>\n");
}
else
fprintf(fp, "<TD>%d</TD><TD>%d</TD>\n",
(int) (get_area_level(pArea) / (MAX_LEVEL+1)),
(int) (get_area_level(pArea) % (MAX_LEVEL+1)));
strcpy(buf, pArea->credits );
strncpy( buf2, buf + 8, 7 ); /* First 8 chars are levels, next 7 Name */
buf2[7] = '\0'; /* Gotta terminate that string! */
fprintf(fp, "<TD>%s</TD>\n", buf2 ); /* Author's Name */
fprintf(fp, "<TD ALIGN=LEFT>%s</TD></TR>\n", buf+16); /* Rest is Area Name */
pArea = pArea->next_sort;
}
fprintf(fp, "</TABLE></CENTER>\n");
fprintf(fp, "<font face=\"Times New Roman\"><center>\n");
sprintf(buf, "This file last updated at %s Eastern Time.\n", ((char *) ctime( ¤t_time )));
fprintf(fp, buf);
fprintf(fp, "</center></font>\n");
fprintf(fp, "<br><br>\n");
/*** DO NOT REMOVE THE FOLLOWING LINK. INCLUSION OF THIS LINK IS
REQUIRED FOR YOUR USE OF THIS FUNCTION. You may change the
target from "_top" to "_new" if you desire.***/
fprintf(fp, "<CENTER><P>Automated area list web update function ©1998 by Nebseni of \n");
fprintf(fp, "<A HREF=\"http://clandestine.mudnet.net\" target=\"_top\">\n");
fprintf(fp, "Clandestine MUD</A></P></CENTER>\n");
/*** DO NOT REMOVE THE PRECEEDING LINK. INCLUSION OF THIS LINK IS
REQUIRED FOR YOUR USE OF THIS FUNCTION. ***/
fprintf(fp, "</body>\n");
fprintf(fp, "</html>\n");
fclose( fp );
fpReserve = fopen( NULL_FILE, "r" );
} /*end if */
return;
}