olc.c
Argila2.0/pp/src/olc.c · 273.8 KB
From the archive Argila2.zip
Download the archive « Back to the archive contents
/**
* \file olc.c
* On-Line Creation module
*
* This module allows you to create, and store objects, rooms, mobiles and some
* progs through the telnet connection. Note: Many of these functions will be
* re-written for a web-based building module.
*
* Copyright 2005, Mary C. Huston, All rights reserved.
* Copyright (C) 2004, Shadows of Isildur: Traithe
*
* The program(s) may be used and/or copied only with written
* permission or in accordance with the terms and conditions
* stipulated in the license from DIKU GAMMA (0.0) and SOI.
*
* \author Mary Huston
* \author Email: auroness@gmail.com
*
******************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <dirent.h>
#include <mysql/mysql.h>
#include "structs.h"
#include "protos.h"
#include "decl.h"
#include "utils.h"
#define ROOM_MAX 100000
#define ZONE_SIZE 1000
#define s(a) send_to_char (a "\n", ch);
extern struct constant_data constant_info [];
void do_wearloc (CHAR_DATA *ch, char *argument, int cmd)
{
OBJ_DATA *obj;
char buf [MAX_STRING_LENGTH];
char loc [MAX_STRING_LENGTH];
int wear_loc, zone = 0, count = 0;
argument = one_argument (argument, buf);
if ( !*buf ) {
send_to_char ("Which wear location did you wish to search for?\n", ch);
return;
}
else snprintf (loc, MAX_STRING_LENGTH, "%s", buf);
if ( (wear_loc = index_lookup(wear_bits, loc)) == -1 ) {
send_to_char ("That isn't a valid wear location.\n", ch);
return;
}
*buf = '\0';
argument = one_argument (argument, buf);
if ( *buf && isdigit(*buf) )
zone = strtol(buf, NULL, 10);
else zone = -1;
*b_buf = '\0';
snprintf (b_buf, MAX_STRING_LENGTH, "Vnum Name(s) Short Desc"
" Clones\tLocation\n\n");
for ( obj = full_object_list; obj; obj = obj->lnext ) {
if ( !obj )
continue;
if ( zone != -1 && obj->zone != zone )
continue;
if ( !IS_SET (obj->obj_flags.wear_flags, 1 << wear_loc) )
continue;
count++;
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH, "%.5d %-16.16s %-28.28s %.3d\t(R) %05d\n",
obj->virtual, obj->name, obj->short_description, 999, obj->in_room);
}
page_string (ch->desc, b_buf);
}
/* some extra arg functions....probably should be moved */
void make_quiet(CHAR_DATA *ch)
{
SET_BIT(ch->act, PLR_QUIET);
}
void save_world (CHAR_DATA *ch)
{
int i;
char buf [MAX_STRING_LENGTH];
snprintf (buf, MAX_STRING_LENGTH, "%s is saving the entire worldfile ... one moment.\n", GET_NAME(ch));
send_to_gods (buf);
for (i = 0; i < MAX_ZONE; i++)
save_rooms (ch, i);
}
void do_zmode(CHAR_DATA *ch, char *argument, int cmd)
{
int mode, zone;
char buf[80];
for (; isspace(*argument); argument++);
if(!*argument) {
send_to_char("You must supply a mode.\n",ch);
return;
}
if(!isdigit(*argument)) {
send_to_char("Argument must be a number.\n",ch);
return;
}
zone = ch->room->zone;
mode = strtol(argument, NULL, 10);
zone_table[zone].reset_mode = mode;
snprintf (buf, MAX_STRING_LENGTH, "Zone %d reset mode changed to %d.\n",zone,mode);
send_to_char(buf,ch);
}
void do_zlife (CHAR_DATA *ch, char *argument, int cmd)
{
int life, zone;
char buf[80];
for (; isspace(*argument); argument++);
if(!*argument) {
send_to_char("You must supply a lifespan.\n",ch);
return;
}
if(!isdigit(*argument)) {
send_to_char("Argument must be a number.\n",ch);
return;
}
zone = vtor (ch->in_room)->zone;
life = strtol(argument, NULL, 10);
zone_table [zone].lifespan = life;
snprintf (buf, MAX_STRING_LENGTH, "Zone %d lifespan changed to %d minutes.\n", zone, life);
send_to_char (buf, ch);
}
void do_freeze(CHAR_DATA *ch, char *argument, int cmd)
{
int num;
char buf[80];
for (; isspace(*argument); argument++);
if (!isdigit(*argument))
{
send_to_char("That is not a valid zone number.\n", ch);
return;
}
num = strtol(argument, NULL, 10);
if ( num == 101 ) {
for ( num = 0; num < MAX_ZONE; num++ )
SET_BIT (zone_table [num].flags, Z_FROZEN);
return;
}
if(num<0 || num>99) {
send_to_char("The zone number must be between 0 and 99.\n",ch);
return;
}
if(IS_SET(zone_table[num].flags,Z_FROZEN)) {
snprintf (buf, MAX_STRING_LENGTH, "Zone %d is already frozen.\n",num);
send_to_char(buf,ch);
return;
} else {
SET_BIT(zone_table[num].flags,Z_FROZEN);
snprintf (buf, MAX_STRING_LENGTH, "Zone %d is now frozen, type 'thaw %d' to re-enable mobile activity.\n",num,num);
send_to_char(buf,ch);
}
}
void do_thaw(CHAR_DATA *ch, char *argument, int cmd)
{
int num;
int unfrozen = 0;
char buf [MAX_STRING_LENGTH];
argument = one_argument (argument, buf);
num = strtol(buf, NULL, 10);
if ( !str_cmp (buf, "all") ) {
for ( num = 0; num < MAX_ZONE; num++ ) {
if ( IS_SET (zone_table [num].flags, Z_FROZEN) )
unfrozen++;
REMOVE_BIT (zone_table [num].flags, Z_FROZEN);
}
snprintf (buf, MAX_STRING_LENGTH, "%d zone(s) unfrozen.\n", unfrozen);
send_to_char (buf, ch);
return;
}
if ( *buf != '0' && !num ) {
send_to_char ("Expected 0..99 or 'all'\n", ch);
return;
}
if ( num < 0 || num > MAX_ZONE ) {
send_to_char ("The zone number must be between 0 and MAX_ZONE.\n", ch);
return;
}
if ( !IS_SET (zone_table [num].flags, Z_FROZEN) )
send_to_char ("That zone isn't frozen.\n", ch);
REMOVE_BIT (zone_table [num].flags, Z_FROZEN);
}
void fwrite_mobile (CHAR_DATA *tmob, FILE *fp)
{
int k, i;
TRIGGER_DATA *trig = NULL;
fprintf (fp, "#%d\n", tmob->mob->virtual);
fprintf (fp, "%s~\n%s~\n", tmob->name, tmob->short_descr);
fprintf (fp, "%s~\n", tmob->long_descr);
fprintf(fp,"%s~\n%lu %ld %d %d %d 5d1+%d %dd%d+%d "
"%d %d %d %d %d %d %d %d\n",
tmob->description,
tmob->act,
tmob->affected_by,
tmob->offense,
tmob->race, /* Was defense */
tmob->armor,
tmob->max_hit,
tmob->mob->damnodice,
tmob->mob->damsizedice,
tmob->mob->damroll,
(int)tmob->time.birth, /* Was clan_2 */
tmob->position,
tmob->default_pos,
tmob->sex,
tmob->mob->merch_seven, /* Was clan_1 */
tmob->deity,
tmob->mob->vehicle_type,
(int)tmob->hmflags);
fprintf (fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
tmob->mob->skinned_vnum,
tmob->circle,
tmob->cell_1,
tmob->mob->carcass_vnum,
tmob->cell_2, /* Formerly tmob->defense_bonus */
tmob->ppoints,
tmob->natural_delay,
tmob->mob->helm_room,
tmob->body_type,
tmob->poison_type,
tmob->nat_attack_type,
tmob->mob->access_flags,
tmob->height,
tmob->frame,
tmob->mob->noaccess_flags,
tmob->cell_3);
fprintf (fp, "%d %d %d %d %d %d %d %d\n",
tmob->str,
tmob->intel,
tmob->wil,
tmob->aur,
tmob->dex,
tmob->con,
tmob->speaks,
tmob->agi);
if ( IS_SET (tmob->flags, FLAG_KEEPER) && !tmob->shop )
REMOVE_BIT (tmob->flags, FLAG_KEEPER);
fprintf (fp, "%d %d\n", tmob->flags, tmob->mob->currency_type);
if ( IS_SET (tmob->flags, FLAG_KEEPER) ) {
fprintf (fp, "%d %d %f %f %f %f %d\n",
tmob->shop->shop_vnum,
tmob->shop->store_vnum,
tmob->shop->markup,
tmob->shop->discount,
tmob->shop->econ_markup1,
tmob->shop->econ_discount1,
tmob->shop->econ_flags1);
if (tmob->mob->merch_seven > 0) {
fprintf (fp, "%f %f %d %f %f %d %f %f %d %f %f %d %f %f %d %f %f %d %d\n",
tmob->shop->econ_markup2,
tmob->shop->econ_discount2,
tmob->shop->econ_flags2,
tmob->shop->econ_markup3,
tmob->shop->econ_discount3,
tmob->shop->econ_flags3,
tmob->shop->econ_markup4,
tmob->shop->econ_discount4,
tmob->shop->econ_flags4,
tmob->shop->econ_markup5,
tmob->shop->econ_discount5,
tmob->shop->econ_flags5,
tmob->shop->econ_markup6,
tmob->shop->econ_discount6,
tmob->shop->econ_flags6,
tmob->shop->econ_markup7,
tmob->shop->econ_discount7,
tmob->shop->econ_flags7,
tmob->shop->nobuy_flags);
}
else {
fprintf (fp, "%f %f %d %f %f %d %d\n",
tmob->shop->econ_markup2,
tmob->shop->econ_discount2,
tmob->shop->econ_flags2,
tmob->shop->econ_markup3,
tmob->shop->econ_discount3,
tmob->shop->econ_flags3,
tmob->shop->nobuy_flags);
}
for ( i = 0; i <= MAX_DELIVERIES; i++ ) {
if ( !tmob->shop->delivery [i] )
break;
fprintf (fp, "%d ", tmob->shop->delivery[i]);
}
fprintf (fp, "-1\n");
fprintf (fp, "%d %d %d %d %d %d %d %d %d %d\n",
tmob->shop->trades_in [0],
tmob->shop->trades_in [1],
tmob->shop->trades_in [2],
tmob->shop->trades_in [3],
tmob->shop->trades_in [4],
tmob->shop->trades_in [5],
tmob->shop->trades_in [6],
tmob->shop->trades_in [7],
tmob->shop->trades_in [8],
tmob->shop->trades_in [9]);
}
for ( k = 0; k < (MAX_SKILLS/10); k++ ){
fprintf (fp, "%d %d %d %d %d %d %d %d %d %d\n",
tmob->skills [k * 10],
tmob->skills [k * 10 + 1],
tmob->skills [k * 10 + 2],
tmob->skills [k * 10 + 3],
tmob->skills [k * 10 + 4],
tmob->skills [k * 10 + 5],
tmob->skills [k * 10 + 6],
tmob->skills [k * 10 + 7],
tmob->skills [k * 10 + 8],
tmob->skills [k * 10 + 9]);
}
fprintf (fp, "%s~\n", tmob->clans);
for ( trig = tmob->triggers; trig; trig = trig->next ){
fprintf (fp, "R\n%d\n%s:%s~\n",
trig->type,
trig->script,
trig->func);
}
return;
}
void fwrite_object (OBJ_DATA *tobj, FILE *fp)
{
AFFECTED_TYPE *af = NULL;
TRIGGER_DATA *trig = NULL;
fprintf (fp, "#%d\n", tobj->virtual);
fprintf (fp, "%s~\n%s~\n%s~\n%s~\n%d %d %ld\n%d %d %d %d\n%d %f\n%d ",
tobj->name,
tobj->short_description,
tobj->description,
tobj->full_description,
tobj->obj_flags.type_flag,
tobj->obj_flags.extra_flags & ~ITEM_LOADS,
tobj->obj_flags.wear_flags,
tobj->o.od.value [0],
tobj->o.od.value [1],
tobj->o.od.value [2],
tobj->o.od.value [3],
tobj->obj_flags.weight,
tobj->silver,
tobj->o.od.value [4]);
if ( tobj->obj_flags.type_flag == ITEM_INK )
fprintf (fp, "\n%s~\n", tobj->ink_color);
if ( tobj->obj_flags.type_flag == ITEM_TENT || tobj->obj_flags.type_flag == ITEM_DWELLING )
fprintf (fp, "\n%s~\n", tobj->indoor_desc);
else if ( tobj->obj_flags.type_flag == ITEM_WORN &&
IS_SET (tobj->obj_flags.extra_flags, ITEM_MASK) ) {
if ( !tobj->desc_keys )
fprintf (fp, "\n~\n");
else
fprintf (fp, "\n%s~\n",tobj->desc_keys);
}
else if ( tobj->obj_flags.type_flag == ITEM_ARMOR &&
IS_SET (tobj->obj_flags.extra_flags, ITEM_MASK) ) {
if ( !tobj->desc_keys )
fprintf (fp, "\n~\n");
else
fprintf (fp, "\n%s~\n",tobj->desc_keys);
}
else {
if ((tobj->obj_flags.type_flag == ITEM_WORN) ||
(tobj->obj_flags.type_flag == ITEM_ARMOR))
tobj->o.od.value [5] = 0;
fprintf (fp, "%d ", tobj->o.od.value [5]);
}
fprintf (fp, "%d %d %d %d %d\n",
tobj->activation,
tobj->quality,
tobj->econ_flags,
tobj->size,
tobj->count);
fprintf (fp, "%f %d %d %d %d 0 0\n",
tobj->coppers,
tobj->clock,
tobj->morphto,
tobj->item_wear,
tobj->material);
if ( tobj->wdesc )
fprintf (fp, "W\n%d\n%s~\n",
tobj->wdesc->language,
tobj->wdesc->description);
for ( af = tobj->xaffected; af; af = af->next )
fprintf (fp, "A\n%d %d\n", af->a.spell.location, af->a.spell.modifier);
for ( trig = tobj->triggers; trig; trig = trig->next )
fprintf (fp, "R\n%d\n%s:%s~\n",
trig->type,
trig->script,
trig->func);
}
void fwrite_room (ROOM_DATA *troom, FILE *fp)
{
XTRA_DESCR_DATA *exptr;
struct room_prog *rp;
int j;
TRIGGER_DATA *nrp = NULL;
if ( !troom->description )
troom->description = add_hash ("No Description Set\n");
fprintf (fp, "#%d\n%s~\n%s~\n",
troom->virtual, troom->name, troom->description);
fprintf (fp, "%d %d %d\n",
troom->zone, troom->room_flags, troom->sector_type);
fprintf (fp, "%d\n", troom->deity);
if ( troom->extra ) {
fprintf (fp, "A\n");
for ( j = 0; j < WR_DESCRIPTIONS; j++ )
fprintf (fp, "%s~\n", troom->extra->weather_desc [j] ?
troom->extra->weather_desc [j] : "");
for ( j = 0; j < 6; j++ )
fprintf (fp, "%s~\n", troom->extra->alas [j] ?
troom->extra->alas [j] : "");
}
for (j = 0; j < 6; j++) {
if ( !troom->dir_option [j] )
continue;
if ( IS_SET (troom->dir_option[j]->exit_info, PASSAGE_SECRET) )
if ( IS_SET (troom->dir_option[j]->exit_info, PASSAGE_TRAP) )
fprintf (fp, "B%d\n", j);
else
fprintf (fp, "H%d\n", j);
else if ( IS_SET (troom->dir_option[j]->exit_info, PASSAGE_TRAP))
fprintf (fp, "T%d\n", j);
else
fprintf (fp, "D%d\n", j);
if ( troom->dir_option [j]->general_description )
fprintf(fp, "%s~\n", troom->dir_option[j]->general_description);
else
fprintf(fp, "~\n");
if ( troom->dir_option [j]->keyword )
fprintf(fp, "%s~\n", troom->dir_option [j]->keyword);
else
fprintf(fp, "~\n");
if ( IS_SET (troom->dir_option [j]->exit_info, PASSAGE_PICKPROOF) )
fprintf (fp, "2");
else if ( IS_SET (troom->dir_option [j]->exit_info, PASSAGE_LOCKED) )
fprintf (fp, "1");
else if ( IS_SET (troom->dir_option [j]->exit_info, PASSAGE_ISDOOR) )
fprintf (fp, "1");
else
fprintf (fp, "0");
fprintf(fp, " %d ", troom->dir_option [j]->key);
fprintf (fp, " %d ", troom->dir_option [j]->pick_penalty);
if ( troom->dir_option [j]->to_room == NOWHERE )
fprintf (fp, "-1\n");
else
fprintf (fp, "%d\n", troom->dir_option [j]->to_room);
}
for ( j = 0; j < 6; j++ ) {
if ( troom->secrets [j] ) {
fprintf (fp, "Q%d\n%d\n", j, troom->secrets [j]->diff);
fprintf (fp, "%s~\n", troom->secrets [j]->stext);
}
}
for ( exptr = troom->ex_description; exptr; exptr = exptr->next )
if ( exptr->description )
fprintf (fp, "E\n%s~\n%s~\n", exptr->keyword, exptr->description);
if ( troom->wdesc )
fprintf (fp, "W\n%d\n%s~\n",
troom->wdesc->language, troom->wdesc->description);
if ( troom->prg ) {
for ( rp = troom->prg; rp; rp = rp->next ) {
fprintf (fp, "P\n");
fprintf (fp, "%s~\n", rp->command);
fprintf (fp, "%s~\n", rp->keys);
fprintf (fp, "%s~\n", rp->prog);
}
}
if ( troom->triggers ) {
for ( nrp = troom->triggers; nrp; nrp = nrp->next ) {
fprintf (fp, "R\n");
fprintf (fp, "%d\n", nrp->type);
fprintf (fp, "%s", nrp->script);
if (nrp->func){
fprintf (fp, ":%s~\n", nrp->func);
}
else {
fprintf (fp, "~\n");
}
}
}
fprintf(fp, "S\n");
}
void save_affect_reset (FILE *fp, CHAR_DATA *tmp_mob, AFFECTED_TYPE *af)
{
CHAR_DATA *proto;
if ( af->type == MAGIC_DRAGGER || af->type == MAGIC_WATCH1 ||
af->type == MAGIC_WATCH2 || af->type == MAGIC_WATCH3 ||
af->type == MAGIC_NOTIFY || af->type == MAGIC_GUARD ||
af->type == MAGIC_SIT_TABLE || af->type == AFFECT_SHADOW ||
af->type == MAGIC_CLAN_NOTIFY )
return;
if ( af->type == MAGIC_ROOM_FIGHT_NOISE )
return;
if ( af->type >= CRAFT_FIRST && af->type <= CRAFT_LAST ) {
fprintf (fp, "C '%s'\n", af->a.craft->subcraft->subcraft_name);
return;
}
proto = vtom (tmp_mob->mob->virtual);
if ( af->type == MAGIC_AFFECT_INFRAVISION &&
IS_SET (tmp_mob->affected_by, AFF_INFRAVIS) )
return;
if ( af->type == MAGIC_AFFECT_INVISIBILITY &&
IS_SET (tmp_mob->affected_by, AFF_INVISIBLE) )
return;
if ( af->type == MAGIC_HIDDEN &&
IS_SET (tmp_mob->affected_by, AFF_HIDE) )
return;
fprintf (fp, "A %d %d %d %d %d %d %d 0 0 0 0 0 0\n",
af->type,
af->a.spell.duration,
af->a.spell.modifier,
af->a.spell.location,
af->a.spell.bitvector,
af->a.spell.sn,
af->a.spell.t);
}
void fwrite_resets (ROOM_DATA *troom, FILE *fp)
{
CHAR_DATA *tmp_mob;
OBJ_DATA *to;
OBJ_DATA *obj;
AFFECTED_TYPE *af;
RESET_DATA *reset;
int j;
int w;
/* Write room header information if we need to write room affects */
if ( troom->affects )
fprintf (fp, "R %d 0 0 0 0 0 0 0 0 0\n", troom->virtual);
for ( af = troom->affects; af; af = af->next ) {
if ( af->type == MAGIC_ROOM_FIGHT_NOISE )
continue;
fprintf (fp, "r %d %d %d %d %d %d %d 0 0 0 0 0 0\n",
af->type,
af->a.spell.duration,
af->a.spell.modifier,
af->a.spell.location,
af->a.spell.bitvector,
af->a.spell.sn,
af->a.spell.t);
}
for (j = 0; j < 6; j++) {
if ( !troom->dir_option [j] )
continue;
if ( IS_SET (troom->dir_option [j]->exit_info, PASSAGE_PICKPROOF) )
fprintf (fp, "D 0 %d %d 2\n", troom->virtual, j);
else if ( IS_SET (troom->dir_option [j]->exit_info, PASSAGE_LOCKED) )
fprintf (fp, "D 0 %d %d 2\n", troom->virtual, j);
else if ( IS_SET (troom->dir_option [j]->exit_info, PASSAGE_ISDOOR) )
fprintf (fp, "D 0 %d %d 1\n", troom->virtual, j);
}
if ( troom->people ) {
for ( tmp_mob = troom->people;
tmp_mob;
tmp_mob = tmp_mob->next_in_room ) {
if ( !IS_NPC (tmp_mob) )
continue;
if ( IS_SET (tmp_mob->act, ACT_STAYPUT) || IS_SET (tmp_mob->act, ACT_MOUNT) )
continue;
fprintf (fp, "M 0 %d 0 %d %d\n", tmp_mob->mob->virtual, troom->virtual, tmp_mob->mount ? tmp_mob->mount->mob->virtual : 0);
if ( tmp_mob->right_hand ) {
to = tmp_mob->right_hand;
fprintf (fp, "G 1 %d 0\n", to->virtual);
for ( to = to->contains; to; to = to->next_content)
fprintf (fp, "P 1 %d 0 %d\n", to->virtual,
to->in_obj->virtual);
}
if ( tmp_mob->left_hand ) {
to = tmp_mob->left_hand;
fprintf (fp, "G 1 %d 0\n", to->virtual);
for ( to = to->contains; to; to = to->next_content)
fprintf (fp, "P 1 %d 0 %d\n", to->virtual,
to->in_obj->virtual);
}
for ( w = 0; w < MAX_WEAR; w++ ) {
if ( !get_equip (tmp_mob, w) )
continue;
obj = get_equip(tmp_mob, w);
fprintf (fp, "E 1 %d 0 %d\n", obj->virtual, w);
if ( obj->contains && (GET_ITEM_TYPE(obj) == ITEM_CONTAINER || GET_ITEM_TYPE(obj) == ITEM_KEYRING || GET_ITEM_TYPE(obj) == ITEM_SHEATH || GET_ITEM_TYPE(obj) == ITEM_QUIVER) )
fprintf (fp, "s 1 %d %d\n", obj->contains->virtual, obj->contains->count);
}
for ( af = tmp_mob->hour_affects; af; af = af->next )
save_affect_reset (fp, tmp_mob, af);
for ( reset = tmp_mob->mob->resets; reset; reset = reset->next )
if ( reset->type == RESET_REPLY )
fprintf (fp, "m %d %s\n", reset->type, reset->command);
else
system_log("ATTEMPT TO SAVE UNKNOWN KIND OF RESET", TRUE);
if ( IS_RIDER (tmp_mob) ) {
for ( w = 0; w < MAX_WEAR; w++ ) {
if ( !get_equip (tmp_mob->mount, w) )
continue;
obj = get_equip(tmp_mob->mount, w);
fprintf (fp, "a 1 %d 0 %d\n", obj->virtual, w);
if ( obj->contains && (GET_ITEM_TYPE(obj) == ITEM_CONTAINER || GET_ITEM_TYPE(obj) == ITEM_KEYRING || GET_ITEM_TYPE(obj) == ITEM_SHEATH || GET_ITEM_TYPE(obj) == ITEM_QUIVER) )
fprintf (fp, "s 1 %d %d\n", obj->contains->virtual, obj->contains->count);
}
}
}
}
}
void do_zsave(CHAR_DATA *ch, char *arg, int cmd)
{
int num, stat, i;
/** Use 226 as cmd to save locked zones**/
if ( !str_cmp (arg, "all") ) {
for ( i = 0; i <= 98; i++ ) {
if((cmd != 226) && (IS_SET(zone_table[i].flags,Z_LOCKED))){
continue;
}
save_rooms (ch, i);
}
if ( port != BUILDER_PORT ) {
i = 99;
if((cmd != 226) && (IS_SET(zone_table[i].flags,Z_LOCKED))){
/** do nothing in these cases **/;
}
else {
save_rooms (ch, i);
}
}
if ( port == BUILDER_PORT ) {
/* system ("../scripts/backup"); //need to write up a script for this */
}
update_crafts_file();
send_to_char ("All in-game zones have been saved.\n", ch);
return;
}
for (; isspace(*arg); arg++){
; /* runnng through the spaces */
}
if (!isdigit(*arg)){
send_to_char("That is not a valid zone number.\n", ch);
return;
}
num = strtol(arg, NULL, 10);
if ( num > 99 || num < 0 ) {
send_to_char ("You must specify a zone between 0 and 99.\n", ch);
return;
}
if ( num == 99 && port == BUILDER_PORT ) {
send_to_char ("Sorry, but this zone can't be saved on the builder port.\n", ch);
return;
}
if((cmd != 226) && (IS_SET(zone_table[num].flags,Z_LOCKED))) {
send_to_char ("That zone is locked. Please try zsaving later.\n", ch);
return;
}
if (num < 0 || num > 99){
send_to_char("The zone must be between 0 and 99.\n", ch);
return;
}
stat = save_rooms (ch, num);
if(!stat){
send_to_char("Saved.\n", ch);
}
else {
send_to_char("Zone save failed - you should #2SHUTDOWN DIE#0 as soon as possible.\n",ch);
}
return;
}
FILE *open_and_rename (CHAR_DATA *ch, char *name, int zone)
{
char buf [MAX_STRING_LENGTH];
FILE *fp;
snprintf (buf, MAX_STRING_LENGTH, "%s/%s.%d", REGIONS, name, zone);
if ( (fp = fopen (buf, "w")) == NULL )
return NULL;
return fp;
}
int save_rooms (CHAR_DATA *ch, int zone)
{
char buf [MAX_INPUT_LENGTH];
CHAR_DATA *tmob;
OBJ_DATA *tobj;
ROOM_DATA *troom;
FILE *fz;
FILE *fm;
FILE *fo;
FILE *fr;
int room_good;
int n;
int tmp;
int empty_rooms = 0;
static int total_empty_rooms = 0;
snprintf (buf, MAX_STRING_LENGTH, "Saving rooms in zone %d.", zone);
system_log(buf, FALSE);
if ( !(fr = open_and_rename (ch, "rooms", zone)) )
return 1;
if ( !(fz = open_and_rename (ch, "resets", zone)) )
return 1;
if ( !(fm = open_and_rename (ch, "mobs", zone)) )
return 1;
if ( !(fo = open_and_rename (ch, "objs", zone)) )
return 1;
fprintf (fz, "#%d\nLead: %s~\n%s~\n%d %d %d %ld %d %d\n",
zone,
zone_table [zone].lead,
zone_table [zone].name,
zone_table [zone].top,
zone_table [zone].lifespan,
zone_table [zone].reset_mode,
zone_table [zone].flags,
zone_table [zone].jailer,
zone_table [zone].jail_room ?
zone_table [zone].jail_room->virtual : 0);
*buf = '\0';
for ( troom = full_room_list; troom; troom = troom->lnext )
if ( troom->zone == zone ) {
room_good = 0;
for ( n = 0; n < 6; n++ )
if ( troom->dir_option [n] &&
troom->dir_option [n]->to_room > 0 )
room_good = 1;
if ( troom->contents || troom->people )
room_good = 1;
if ( strncmp (troom->description, "No Description Set", 18) )
room_good = 1;
if ( room_good ) {
fwrite_room (troom, fr);
fwrite_resets (troom, fz);
} else {
empty_rooms++;
total_empty_rooms++;
}
}
if ( empty_rooms ) {
snprintf (buf, MAX_STRING_LENGTH, "%d empty rooms were not saved for zone %d.",
empty_rooms, zone);
system_log(buf, FALSE);
strcat (buf, "\n");
send_to_char (buf, ch);
}
for ( tmob = full_mobile_list; tmob; tmob = tmob->mob->lnext )
if ( tmob->mob->zone == zone && !tmob->deleted && !IS_SET (tmob->act, ACT_STAYPUT) )
fwrite_mobile (tmob, fm);
for ( tobj = full_object_list; tobj; tobj = tobj->lnext )
if ( tobj->zone == zone && tobj->virtual != -1 && tobj->virtual != 42 )
if ( !tobj->deleted ||
get_obj_in_list_num (tobj->virtual, object_list) ) {
/* Remove clan information from extra flags before
saving to disk...put it back afterwords */
tmp = tobj->obj_flags.extra_flags;
REMOVE_BIT (tobj->obj_flags.extra_flags, ITEM_LEADER);
REMOVE_BIT (tobj->obj_flags.extra_flags, ITEM_MEMBER);
REMOVE_BIT (tobj->obj_flags.extra_flags, ITEM_OMNI);
fwrite_object (tobj, fo);
tobj->obj_flags.extra_flags = tmp;
}
fprintf (fr, "$~\n");
fprintf (fo, "$~\n");
fprintf (fm, "$~\n");
fprintf (fz, "S\n");
fclose (fr);
fclose (fz);
fclose (fm);
fclose (fo);
return 0;
}
void do_rclone (CHAR_DATA *ch, char *argument, int cmd)
{
int i;
ROOM_DATA *source_room;
ROOM_DATA *target_room;
char buf1 [MAX_INPUT_LENGTH];
char buf2 [MAX_INPUT_LENGTH];
argument = one_argument (argument, buf1);
if ( !strtol(buf1, NULL, 10) ) {
send_to_char("You must supply a virtual room number.\n", ch);
return;
}
argument = one_argument (argument, buf2);
if ( !strtol(buf2, NULL, 10) )
target_room = ch->room;
else {
if ( !(target_room = vtor (strtol(buf2, NULL, 10))) ) {
send_to_char ("No such target room.\n", ch);
return;
}
}
if ( !(source_room = vtor (strtol(buf1, NULL, 10))) ) {
send_to_char ("No such source room.\n", ch);
return;
}
target_room->name = add_hash(source_room->name);
target_room->description = add_hash(source_room->description);
target_room->sector_type = source_room->sector_type;
target_room->room_flags = source_room->room_flags;
target_room->zone = target_room->virtual / ZONE_SIZE;
if ( source_room->extra ) {
CREATE (target_room->extra, ROOM_EXTRA_DATA, 1);
for ( i = 0; i < WR_DESCRIPTIONS; i++ ) {
if ( source_room->extra->weather_desc [i] )
target_room->extra->weather_desc [i] =
str_dup (source_room->extra->weather_desc [i]);
}
} else
target_room->extra = NULL;
send_to_char ("Done.\n", ch);
}
void do_rdoor (CHAR_DATA *ch, char *argument, int cmd)
{
char buf1[256], buf2[256];
int dir;
ROOM_DATA *room;
half_chop(argument, buf1, buf2);
switch (*buf1) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
room = vtor (ch->in_room);
if ( !room->dir_option [dir] ) {
send_to_char("There is no exit in that direction.\n", ch);
return;
}
SET_BIT (room->dir_option [dir]->exit_info, PASSAGE_ISDOOR);
if ( !*buf2 )
strcpy (buf2, "door");
room->dir_option [dir]->keyword = add_hash (buf2);
send_to_char ("Done.\n", ch);
}
/* *
* funtion: do_review < e.g.> review <name> *
* *
* 09/17/2004 [JWW] - Fixed an instances where mysql result was not freed *
* */
void do_review (CHAR_DATA *ch, char *argument, int cmd)
{
int silent_review = 0;
CHAR_DATA *review_ch;
MYSQL_RES *result;
char buf [MAX_INPUT_LENGTH];
char name [MAX_INPUT_LENGTH];
argument = one_argument (argument, name);
if ( IS_NPC (ch) ) {
send_to_char ("You must RETURN before reviewing any applications.\n", ch);
return;
}
if ( port == BUILDER_PORT ) {
send_to_char ("Applications may only be reviewed on the player port.\n", ch);
return;
}
if ( !isalpha (*name) ) {
send_to_char ("Illegal name.\n", ch);
return;
}
argument = one_argument (argument, buf);
if ( *buf == '!' )
silent_review = 1;
if ( !(review_ch = load_pc (name)) ) {
send_to_char ("There is no pfile associated with that name, "
"sorry.\n", ch);
return;
}
if ( IS_MORTAL(ch) && (!is_newbie (review_ch) || IS_SET (review_ch->plr_flags, PRIVATE)) ) {
send_to_char ("There is no playerfile associated with that name, sorry.\n", ch);
return;
}
if ( review_ch->pc->create_state != 1 ) {
snprintf (buf, MAX_STRING_LENGTH, "It appears that this application has already been reviewed and responded to.\n");
send_to_char (buf, ch);
unload_pc (review_ch);
return;
}
if ( is_being_reviewed (review_ch->tname, ch->desc->account->name) ) {
snprintf (buf, MAX_STRING_LENGTH, "That application is currently checked out - try again later.\n");
send_to_char (buf, ch);
unload_pc (review_ch);
return;
}
spitstat (review_ch, ch->desc);
ch->delay_type = DEL_APP_APPROVE;
ch->delay = 3 * 60;
ch->delay_who = str_dup (name);
mysql_safe_query ("SELECT * FROM virtual_boards WHERE board_name = 'Applications' AND subject LIKE '%% %s'", review_ch->tname);
if ( ( result = mysql_store_result ( database ) ) != NULL ) {
if ( mysql_num_rows ( result ) >= 1 ) {
send_to_char ("\n#6Please type HISTORY to review previous responses to this application.#0\n", ch);
}
mysql_free_result ( result );
result = NULL;
}
send_to_char ("\n#2Please ACCEPT or DECLINE this application.#0\n", ch);
if ( !is_yours (review_ch->tname, ch->desc->account->name) ) {
mysql_safe_query ("INSERT INTO reviews_in_progress VALUES ('%s', '%s', UNIX_TIMESTAMP())", review_ch->tname, ch->desc->account->name);
}
unload_pc (review_ch);
}
void show_reg_by_name (CHAR_DATA *ch, char *reg_name)
{
char buf [MAX_INPUT_LENGTH];
int index = 0;
int count = 0;
REGISTRY_DATA *reg = NULL;
char *temp_arg = NULL;
if ( !*reg_name )
strcpy (buf, "registry");
else
strcpy (buf, reg_name);
send_to_char ("\n", ch);
if ( (index = lookup_value (buf, REG_REGISTRY)) == -1 ) {
send_to_char ("No such registry.\n", ch);
return;
}
reg = registry [index];
for ( reg = registry [index]; reg; reg = reg->next ) {
if (index == REG_MISC ) {
temp_arg = lookup_string (reg->value, REG_MISC_NAMES);
snprintf (buf, MAX_STRING_LENGTH, " %20s %s\n",
temp_arg,
reg->string);
}
else if ( index == REG_CAP || index == REG_OV || index == REG_LV ){
temp_arg = lookup_string (reg->value, REG_SKILLS);
snprintf (buf, MAX_STRING_LENGTH, " %20s %s\n",
temp_arg,
reg->string);
}
else if ( index == REG_MAX_RATES){
temp_arg = skill_data[reg->value].skill_name;
snprintf (buf, MAX_STRING_LENGTH, " %20s %s\n",
temp_arg,
reg->string);
}
else
snprintf (buf, MAX_STRING_LENGTH, " %-15s%s", reg->string, ++count % 4 ? "" : "\n");
send_to_char (buf, ch);
}
send_to_char ("\n", ch);
}
void olist_show (OBJ_DATA *obj, int type, int header)
{
char buf [MAX_STRING_LENGTH];
char wear_loc [MAX_STRING_LENGTH];
char armor_type [MAX_STRING_LENGTH];
switch ( type ) {
case ITEM_WEAPON:
if ( header )
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"Virt# Dam Weight Value Delay Qty 1st-key Short Description\n");
(void)one_argument (obj->name, buf);
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"%.5d%s%1dd%-2d %3d.%.2d %5d %3d %2d %-13.13s %-28.28s\n",
obj->virtual, *obj->full_description ? " ": "*",
obj->o.weapon.dice, obj->o.weapon.sides,
obj->obj_flags.weight / 100, obj->obj_flags.weight % 100,
obj->obj_flags.cost, obj->o.weapon.delay, obj->quality,
buf, obj->short_description);
break;
case ITEM_ARMOR:
if ( header )
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"Virt# AC Weight Value Type Wear-Flgs 1st-key Short Description\n");
(void)one_argument (obj->name, buf);
switch ( obj->o.armor.armor_type ) {
case 0: strcpy (armor_type, "Quilted "); break;
case 1: strcpy (armor_type, "Leather "); break;
case 2: strcpy (armor_type, "Ring "); break;
case 3: strcpy (armor_type, "Scale "); break;
case 4: strcpy (armor_type, "Mail "); break;
case 5: strcpy (armor_type, "Plate "); break;
default: strcpy (armor_type, "????? "); break;
}
*wear_loc = '\0';
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_FINGER) )
strcat (wear_loc, "FING ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_NECK) )
strcat (wear_loc, "NECK ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_BODY) )
strcat (wear_loc, "BODY ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_HEAD) )
strcat (wear_loc, "HEAD ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_LEGS) )
strcat (wear_loc, "LEGS ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_FEET) )
strcat (wear_loc, "FEET ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_HANDS) )
strcat (wear_loc, "HAND ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_ARMS) )
strcat (wear_loc, "ARMS ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_SHIELD) )
strcat (wear_loc, "SHLD ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_ABOUT) )
strcat (wear_loc, "ABOT ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_WAIST) )
strcat (wear_loc, "WSTE ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_WRIST) )
strcat (wear_loc, "WRST ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_HAIR) )
strcat (wear_loc, "HAIR ");
if ( IS_SET (obj->obj_flags.wear_flags, ITEM_WEAR_FACE) )
strcat (wear_loc, "FACE ");
if ( strlen (wear_loc) > 10 ) {
wear_loc [14] = '+';
wear_loc [15] = '\0';
}
else
while ( strlen (wear_loc) < 10 )
strcat (wear_loc, " ");
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"%.5d%s%2d %3d.%.2d %5d %s %s%-13.13s %-24.24s\n",
obj->virtual, *obj->full_description ? " " : "*",
obj->o.armor.armor_value,
obj->obj_flags.weight / 100, obj->obj_flags.weight % 100,
obj->obj_flags.cost, armor_type, wear_loc, buf,
obj->short_description);
break;
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
if ( header )
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"Virt# Weight ##drnk Cap Contents Short Description\n");
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"%.5d%s %5d.%02d %5d %5d %-25s %s\n",
obj->virtual,
(obj->full_description && *obj->full_description) ? " " : "*",
obj->obj_flags.weight / 100, obj->obj_flags.weight % 100,
obj->o.drinkcon.volume,
obj->o.drinkcon.capacity,
!obj->o.drinkcon.volume ? "(empty)" :
vtoo (obj->o.drinkcon.liquid) ?
vtoo (obj->o.drinkcon.liquid)->short_description : "not set",
obj->short_description);
break;
case ITEM_FOOD:
if ( header )
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"Virt # Foodval bites spel1 spel2 spel3 spel4 Short Description\n");
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"%.5d%s %5d %5d %5d %5d %5d %5d %s\n",
obj->virtual,
(obj->full_description && *obj->full_description) ? " " : "*",
obj->o.food.food_value,
obj->o.food.bites,
obj->o.food.spell1,
obj->o.food.spell2,
obj->o.food.spell3,
obj->o.food.spell4,
obj->short_description);
break;
case -1:
default:
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH,
"%.5d%s %5d %-25.25s %-25.25s",
obj->virtual, (obj->full_description && *obj->full_description)
? " " : "*",
obj->obj_flags.cost, obj->name,
obj->short_description);
if ( obj->obj_flags.type_flag == ITEM_DRINKCON && obj->o.od.value[1] && obj->o.od.value[2] && vtoo(obj->o.od.value[2]))
snprintf (b_buf + strlen(b_buf), MAX_STRING_LENGTH, " #6(%s)#0", vtoo(obj->o.od.value[2])->short_description);
strcat (b_buf, "\n");
break;
}
}
void do_olist (CHAR_DATA *ch, char *argument, int cmd)
{
int header = 1;
int type = -1;
int inclusive;
int zone = -1;
int yes_key1 = 0;
int yes_key2 = 0;
int yes_key3 = 0;
int count = 0;
OBJ_DATA *obj;
char key1 [MAX_STRING_LENGTH] = { '\0' };
char key2 [MAX_STRING_LENGTH] = { '\0' };
char key3 [MAX_STRING_LENGTH] = { '\0' };
char buf [MAX_STRING_LENGTH];
argument = one_argument (argument, buf);
if ( !*buf ) {
send_to_char ("Selection Parameters:\n\n", ch);
send_to_char (" +/-<object keyword> Include/exclude object keyword.\n", ch);
send_to_char (" <zone> Objects from zone only.\n", ch);
send_to_char (" <item-type> Include items of item-type.\n", ch);
send_to_char ("\nExample: olist +sword -rusty weapon 10\n", ch);
send_to_char ("will only get non-rusty swords of type weapon from zone 10.\n", ch);
return;
}
while ( *buf ) {
inclusive = 1;
if ( strlen (buf) > 1 && isalpha (*buf) &&
(type = index_lookup (item_types, buf)) != -1 ) {
argument = one_argument (argument, buf);
continue;
}
if ( isdigit (*buf) ) {
if ( (zone = strtol(buf, NULL, 10)) >= MAX_ZONE ) {
send_to_char ("Zone not in range 0..99\n", ch);
return;
}
argument = one_argument (argument, buf);
continue;
}
switch ( *buf ) {
case '-':
inclusive = 0;
if ( !buf [1] ) {
send_to_char ("Expected keyname after 'k'.\n", ch);
return;
}
if ( !*key1 ) {
yes_key1 = inclusive;
strcpy (key1, buf + 1);
} else if ( !*key2 ) {
yes_key2 = inclusive;
strcpy (key2, buf + 1);
} else if ( *key3 ) {
send_to_char ("Sorry, at most three keywords.\n", ch);
return;
} else {
yes_key3 = inclusive;
strcpy (key3, buf + 1);
}
break;
case '+':
if ( !buf [1] ) {
send_to_char ("Expected keyname after 'k'.\n", ch);
return;
}
if ( !*key1 ) {
yes_key1 = inclusive;
strcpy (key1, buf + 1);
} else if ( !*key2 ) {
yes_key2 = inclusive;
strcpy (key2, buf + 1);
} else if ( *key3 ) {
send_to_char ("Sorry, at most three keywords.\n", ch);
return;
} else {
yes_key3 = inclusive;
strcpy (key3, buf + 1);
}
break;
case 'z':
argument = one_argument (argument, buf);
if ( !isdigit (*buf) || strtol(buf, NULL, 10) >= MAX_ZONE ) {
send_to_char ("Expected valid zone after 'z'.\n", ch);
return;
}
zone = strtol(buf, NULL, 10);
break;
}
argument = one_argument (argument, buf);
}
*b_buf = '\0';
for ( obj = full_object_list; obj; obj = obj->lnext ) {
if ( zone != -1 && obj->zone != zone )
continue;
if ( type != -1 && obj->obj_flags.type_flag != type )
continue;
if ( *key1 ) {
if ( yes_key1 && !name_is (key1, obj->name) )
continue;
else if ( !yes_key1 && name_is (key1, obj->name) )
continue;
}
if ( *key2 ) {
if ( yes_key2 && !name_is (key2, obj->name) )
continue;
else if ( !yes_key2 && name_is (key2, obj->name) )
continue;
}
if ( *key3 ) {
if ( yes_key3 && !name_is (key3, obj->name) )
continue;
else if ( !yes_key3 && name_is (key3, obj->name) )
continue;
}
count++;
if ( count < 200 )
olist_show (obj, type, header);
header = 0;
}
if ( count > 200 ) {
snprintf (buf, MAX_STRING_LENGTH, "You have selected %d objects (too many to print).\n",
count);
send_to_char (buf, ch);
return;
}
page_string (ch->desc, b_buf);
}
/* *
* funtion: do_show < e.g.> show (k|a|l|v|m|n|o|q|r|u|z) *
* *
* */
void do_show (CHAR_DATA *ch, char *argument, int cmd)
{
CHAR_DATA *tch;
DESCRIPTOR_DATA *d;
char buf [MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH]; /* type of show (k|a|l... */
char buf2[MAX_STRING_LENGTH]; /* first option/value */
char buf3[MAX_STRING_LENGTH]; /* second option/value */
char buf4[MAX_STRING_LENGTH]; /* third option/value */
char tmp[MAX_STRING_LENGTH];
char output[MAX_STRING_LENGTH];
char *date = NULL;
char *obj_name;
char *mob_name;
char *clan_name = {'\0'};
char *zone_str;
int mtop=0;
int count;
int count2;
int otop=0;
int numdex;
int index;
int count_total_rooms;
int docs = 0;
int keepers_only = 0;
int got_line = 0;
int ok_only = 0;
int craft_tot=0;
int big_counts_only = 0;
int undesc_only = 0;
int stayput = 0;
int chars = 0;
int accounts = 0;
int search_type = 0;
bool found = FALSE;
OBJ_DATA *objdex;
CHAR_DATA *chardex;
ROOM_DATA *troom;
SUBCRAFT_HEAD_DATA *craft;
MYSQL_RES *result;
MYSQL_ROW row;
time_t current_time;
arg_splitter(4, argument, buf1, buf2, buf3, buf4);
if ( IS_MORTAL (ch) && !IS_NPC(ch) && !ch->pc->is_guide) {
send_to_char ("Eh?\n", ch);
return;
}
if ( ch->pc->is_guide && IS_MORTAL(ch) ) {
if ( *buf1 != 'l' && *buf1 != 'L' ) {
send_to_char ("Type SHOW L to get a list of applications in the queue.\n", ch);
return;
}
}
if ( !*buf1 ) {
s (" a per zone stats");
s (" c characters matching search");
s (" k shopkeepers");
s (" l applications");
s (" m mobiles");
s (" n clans for mobiles");
s (" o objects");
s (" p PCs with specified points");
s (" q objects with ok flag");
s (" r rooms");
s (" s summary building info");
s (" u undescribed rooms");
s (" v registry.");
s (" z zones");
}
switch (*buf1) {
case 'a': /** Summary of rooms, players, mob, and objects by zone **/
snprintf( tmp, MAX_STRING_LENGTH, " Name Rooms Plyrs Mobs Objs\n\n");
for(index = 0; index < MAX_ZONE; index++) {
if(strcmp(zone_table[index].name, "Empty Zone")) {
snprintf( tmp + strlen(tmp), MAX_STRING_LENGTH, "%2d - %-16.16s", index, zone_table[index].name);
count = 0;
numdex = 0;
for ( troom = full_room_list; troom; troom = troom->lnext ){
if ( troom->zone == index ) {
count++;
if(!(strncmp(troom->description, "No Description Set", 18))){
numdex++;
}
}
}
snprintf (tmp + strlen(tmp), MAX_STRING_LENGTH, "%10d/%-4d", count, numdex);
count = 0;
count2 = 0;
for(chardex = character_list; chardex; chardex = chardex->next) {
if ( !IS_NPC(chardex) )
continue;
/* counts PCs only in room Q000 */
if ( chardex->in_room / 1000 == index )
count++;
}
for (chardex = character_list; chardex; chardex = chardex->next){
if (!IS_NPC(chardex) && chardex->room && chardex->room->zone == index){
count2++;
}
}
snprintf (tmp + strlen(tmp), MAX_STRING_LENGTH, "%6d%10d", count2, count);
count = 0;
/** will count thee different types of objecs, not a full count of all items **/
for ( objdex = object_list; objdex; objdex = objdex->next ){
if ( !objdex->deleted && objdex->zone == index ){
count++;
}
}
snprintf (tmp + strlen(tmp), MAX_STRING_LENGTH,"%10d\n",count);
}
}
page_string(ch->desc,tmp);
break;
case 'c': /** show characters matching search paramaters **/
if ( !str_cmp (buf2, "keyword") )
search_type = SEARCH_KEYWORD;
else if ( !str_cmp (buf2, "sdesc") )
search_type = SEARCH_SDESC;
else if ( !str_cmp (buf2, "ldesc") )
search_type = SEARCH_LDESC;
else if ( !str_cmp (buf2, "fdesc") )
search_type = SEARCH_FDESC;
else if ( !str_cmp (buf2, "clan") )
search_type = SEARCH_CLAN;
else if ( !str_cmp (buf2, "skill") )
search_type = SEARCH_SKILL;
else if ( !str_cmp (buf2, "room") )
search_type = SEARCH_ROOM;
else if ( !str_cmp (buf2, "race") )
search_type = SEARCH_RACE;
else if ( !str_cmp (buf2, "level") && GET_TRUST (ch) >= 5 )
search_type = SEARCH_LEVEL;
else {
if ( GET_TRUST (ch) < 5 )
send_to_char ("Search for: keyword, sdesc, ldesc, fdesc, clan, skill, or room.\n", ch);
else send_to_char ("Search for: keyword, sdesc, ldesc, fdesc, clan, skill, room, or level.\n", ch);
return;
}
result = mysql_player_search (search_type, buf3);
if ( !result || !mysql_num_rows (result) ) {
send_to_char ("No playerfiles matching your search were found.\n", ch);
if ( result )
mysql_free_result (result);
return;
}
snprintf (buf, MAX_STRING_LENGTH, "#6Playerfiles Matching Search: %d#0\n\n", (int)mysql_num_rows(result));
index = 1;
while ( (row = mysql_fetch_row (result)) ) {
if ( strtol(row[8], NULL, 10) == 2 )
snprintf (buf3, MAX_STRING_LENGTH, " #2(Approved)#0");
else if ( strtol(row[8], NULL, 10) == 4 )
snprintf (buf3, MAX_STRING_LENGTH, " #1(Deceased)#0");
else if ( strtol(row[8], NULL, 10) == 3 )
snprintf (buf3, MAX_STRING_LENGTH, " #5(Suspended)#0");
else snprintf (buf3, MAX_STRING_LENGTH, " #6(Pending)#0");
snprintf (buf2, MAX_STRING_LENGTH, "%4d. %-20s%s\n", index, row[0], buf3);
if ( strlen(buf) + strlen(buf2) >= MAX_STRING_LENGTH ){
send_to_char("Too many playerfiles being accesed - Please restrict your search", ch);
break;
}
else snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "%s", buf2);
index++;
}
page_string (ch->desc, buf);
mysql_free_result (result);
return;
case 'v': /** registry entry **/
show_reg_by_name (ch, buf2);
break;
case 'p': /** show by point criteria **/
if ( !*buf2 ) {
send_to_char ("What did you wish the point criterion to be?\n", ch);
return;
}
if ( !isdigit (*buf2) ) {
send_to_char ("Please specify a number of points.\n", ch);
return;
}
*buf = '\0';
for (d = descriptor_list; d; d = d->next) {
if (d->character && IS_MORTAL (d->character) && (d->connected == CON_PLYNG) && (d->character->in_room != NOWHERE) &&
d->account && d->account->roleplay_points <= strtol(buf2, NULL, 10) &&
(time(0) - d->character->pc->last_rpp >= 60*60*24*60) ) {
found = TRUE;
snprintf (output, MAX_STRING_LENGTH, "%-20s - %s [%d]\n",
d->character->tname,
vtor (d->character->in_room)->name,
vtor (d->character->in_room)->virtual);
if ( strlen(output) + strlen(buf) >= MAX_STRING_LENGTH ) {
send_to_char ("Too many matches found - please use a more selective criterion!\n", ch);
return;
}
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "%s", output);
}
}
if ( found ) {
snprintf (output, MAX_STRING_LENGTH, "#2The following PCs online currently have %d roleplay points or less and\n"
"have not been awarded or deducted within the last 60 days:#0\n\n%s", (int)strtol(buf2, NULL, 10), buf);
}
else {
snprintf (output, MAX_STRING_LENGTH, "#1No PCs currently online have %d roleplay points or less who have not\n"
"been awarded or deducted within the last 60 days.#0\n", (int)strtol(buf2, NULL, 10));
}
page_string (ch->desc, output);
break;
case 'l': /** Pending applications **/
date = timestr(date);
snprintf ( buf, MAX_STRING_LENGTH, "\nApplication Queue, as of #2%s#0:\n\n", date );
mem_free ( date ) ;
send_to_char (buf, ch);
mysql_safe_query ("SELECT name,birth,account,plrflags FROM %s.pfiles WHERE create_state = 1 ORDER BY birth ASC", PFILES_DATABASE);
result = mysql_store_result (database);
if ( result ) {
while ( (row = mysql_fetch_row(result)) ) {
tch = load_pc (row[0]);
if ( !tch )
continue;
if ( IS_MORTAL (ch) && (!is_newbie(tch))) {
unload_pc (tch);
continue;
}
got_line++;
snprintf (buf, MAX_STRING_LENGTH, " %-20s", row[0]);
current_time = strtol(row[1], NULL, 10);
date = (char *) malloc (256) ;
date[0] = '\0' ;
if ( asctime_r ( localtime ( ¤t_time ), date ) != NULL ) {
date [ strlen ( date ) - 1 ] = '\0';
}
if ( (time(0) - current_time) - (60*60*48) >= 1 )
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "#1[Submitted: %s]#0", date);
else if ( (time(0) - current_time) - (60*60*24) >= 1 )
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "#3[Submitted: %s]#0", date);
else snprintf (buf + strlen(buf), MAX_STRING_LENGTH, "#2[Submitted: %s]#0", date);
mem_free ( date );
if ( !IS_NPC(ch) && is_newbie(tch) && !IS_MORTAL(ch) )
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, " #6(New)#0");
if ( !IS_NPC(ch) && is_yours (row[0], ch->pc->account) )
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, " #3(Yours)#0");
else if ( !IS_NPC(ch) && is_being_reviewed (row[0], ch->pc->account) )
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, " #2(Checked Out)#0");
if ( !IS_NPC(ch) && IS_SET (tch->plr_flags, PRIVATE) && !IS_MORTAL(ch) )
snprintf (buf + strlen(buf), MAX_STRING_LENGTH, " #1(Private)#0");
strcat (buf, "\n");
send_to_char (buf, ch);
unload_pc (tch);
}
mysql_free_result (result);
result = NULL;
}
if ( !got_line )
send_to_char (" None\n", ch);
break;
case 'k': /** shows shopkeepers and thier location **/
keepers_only = 1;
mob_name = buf3;
zone_str = NULL;
if ( !isdigit (*buf2) )
mob_name = str_dup(buf2);
else
zone_str = buf2;
snprintf (tmp, MAX_STRING_LENGTH, "Vnum K Name(s) Short desc"
" Clones\t\tIn Room\n\n");
for ( chardex = full_mobile_list; chardex; chardex = chardex->mob->lnext ) {
if ( !IS_NPC (chardex) )
continue;
if ( keepers_only && !chardex->shop )
continue;
if ( zone_str && chardex->mob->zone != strtol(zone_str, NULL, 10) )
continue;
if ( !*chardex->name )
continue;
if ( (*mob_name && strstr(chardex->name,mob_name)) || !*mob_name) {
if ( IS_SET (chardex->flags, FLAG_KEEPER) )
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "%.5d * %-16.16s %-28.28s %.3d\t\t%.5d\n", chardex->mob->virtual, chardex->name, chardex->short_descr, 999, chardex->in_room);
}
}
page_string (ch->desc, tmp);
break;
case 'm': /** shows summary of all mobiles **/
mob_name = buf3;
zone_str = NULL;
if ( !isdigit (*buf2) )
mob_name = str_dup(buf2);
else
zone_str = buf2;
snprintf (tmp, MAX_STRING_LENGTH, "Vnum K Name(s) Short desc\n\n");
for ( chardex = full_mobile_list; chardex; chardex = chardex->mob->lnext ) {
if ( !IS_NPC (chardex) )
continue;
if ( zone_str && chardex->mob->zone != strtol(zone_str, NULL, 10) )
continue;
if ( !*chardex->name )
continue;
if ( ((*mob_name && strstr(chardex->name,mob_name)) ||!*mob_name)){
if (!IS_SET (chardex->flags, FLAG_KEEPER)){
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH,
"%.5d %-16.16s %-28.28s\n",
chardex->mob->virtual, chardex->name,
chardex->short_descr);
}
else{
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH,
"%.5d * %-16.16s %-28.28s\n",
chardex->mob->virtual, chardex->name,
chardex->short_descr);
}
}
}
page_string (ch->desc, tmp);
break;
case 'n': /** NPC clans members **/
clan_name = buf3;
zone_str = NULL;
if ( !isdigit (*buf2) )
clan_name = str_dup(buf3);
else
zone_str = buf2;
snprintf(tmp, MAX_STRING_LENGTH, "Vnum Name(s) Short desc\n");
for ( chardex = full_mobile_list; chardex; chardex = chardex->mob->lnext ) {
if ( !IS_NPC (chardex) )
continue;
if ( zone_str && chardex->mob->zone != strtol(zone_str, NULL, 10) )
continue;
if ( !*chardex->name )
continue;
if (!*chardex->clans)
continue;
if ((*clan_name && strstr(chardex->clans, clan_name)) || !*clan_name){
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "%.5d %-12.12s %-s\n\t%s\n\n", chardex->mob->virtual, chardex->name, chardex->short_descr, chardex->clans);
}
}
page_string (ch->desc, tmp);
break;
case '!': /** will show only large groups of specified object **/
big_counts_only = 1;
case 'q': /** Object only with ok flag **/
ok_only = 1;
case 'o': /** Summary of all objects **/
obj_name = str_dup(buf3);
zone_str = NULL;
if ( !isdigit (*buf2) )
obj_name = buf2;
else
zone_str = buf2;
snprintf (tmp, MAX_STRING_LENGTH, "Vnum Name(s) Short desc"
" Clones\tLocation\n\n");
for ( objdex = full_object_list; objdex; objdex = objdex->lnext ) {
if ( zone_str && objdex->zone != strtol(zone_str, NULL, 10) )
continue;
if ( ok_only && !IS_SET (objdex->obj_flags.extra_flags, ITEM_OK) )
continue;
if ( big_counts_only && objdex->count < 100 )
continue;
if ( (*obj_name && strstr (objdex->name, obj_name)) || !*obj_name ) {
if ( !*objdex->name )
continue;
if ( objdex->in_obj )
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "%.5d %-16.16s %-28.28s %.3d\t(I)%.5d#0\n", objdex->virtual, objdex->name, objdex->short_description, 999, objdex->in_obj->virtual);
else if ( objdex->carried_by )
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "%.5d %-16.16s %-28.28s %.3d\t(C)%.5d#0\n", objdex->virtual, objdex->name, objdex->short_description, 999, objdex->carried_by->mob ? objdex->carried_by->mob->virtual : 0);
else if ( objdex->equiped_by )
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "%.5d %-16.16s %-28.28s %.3d\t(E)%.5d#0\n", objdex->virtual, objdex->name, objdex->short_description, 999, objdex->equiped_by->mob ? objdex->equiped_by->mob->virtual : 0);
else
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "%.5d %-16.16s %-28.28s %.3d\t(R) %05d#0\n", objdex->virtual, objdex->name, objdex->short_description, 999, objdex->in_room);
}
}
page_string (ch->desc, tmp);
break;
case 'u': /** Shows undescribed room only */
*tmp = 0;
for ( troom = full_room_list; troom; troom = troom->lnext ) {
if ( strncmp (troom->description, "No Description Set", 18) )
continue;
if ( IS_SET (troom->room_flags, STORAGE) )
continue;
snprintf (tmp + strlen(tmp), MAX_STRING_LENGTH, "[%5d] %s", troom->virtual,troom->name);
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "\n");
}
page_string (ch->desc, tmp);
return;
case 'r': /** All Rooms **/
if ( buf1 [1] == '*' )
ok_only = 1;
*tmp = 0;
for ( troom = full_room_list; troom; troom = troom->lnext ) {
if ( *buf3 && strtol(buf3, NULL, 10) > troom->virtual)
continue;
if ( *buf4 && strtol(buf4, NULL, 10) < troom->virtual)
continue;
if ( !ok_only && troom->zone != strtol(buf2, NULL, 10) )
continue;
if ( undesc_only && !IS_SET (troom->room_flags, STORAGE) &&
strncmp (troom->description, "No Description Set", 18) )
continue;
if ( ok_only && !IS_SET (troom->room_flags, ROOM_OK) )
continue;
if ( IS_SET (troom->room_flags, STORAGE) )
strcat (tmp, "S");
else
strcat (tmp, " ");
if ( troom->prg )
strcat (tmp, "P");
else
strcat (tmp, " ");
snprintf (tmp + strlen(tmp), MAX_STRING_LENGTH, "[%5d] %s", troom->virtual,troom->name);
for ( numdex = 0; numdex < 6; numdex++ ) {
if ( troom->dir_option [numdex] &&
troom->dir_option [numdex]->to_room != -1) {
switch (numdex) {
case 0:
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, " N [%5d]",
troom->dir_option [numdex]->to_room);
break;
case 1:
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, " E [%5d]",
troom->dir_option [numdex]->to_room);
break;
case 2:
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, " S [%5d]",
troom->dir_option [numdex]->to_room);
break;
case 3:
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, " W [%5d]",
troom->dir_option [numdex]->to_room);
break;
case 4:
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, " U [%5d]",
troom->dir_option [numdex]->to_room);
break;
case 5:
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, " D [%5d]",
troom->dir_option [numdex]->to_room);
break;
}
}
}
snprintf (tmp + strlen (tmp), MAX_STRING_LENGTH, "\n");
}
page_string (ch->desc, tmp);
return;
case 'z': /** Shows zone name and numbers **/
for ( index = 0; index < MAX_ZONE; index += 5 ) {
snprintf (tmp, MAX_STRING_LENGTH, "##%2d %-11.11s ##%2d %-11.11s ##%2d %-11.11s ##%2d %-11.11s ##%2d %-11.11s\n", index, zone_table[index].name,
index + 1, zone_table [index+1].name, index + 2, zone_table [index+2].name, index + 3, zone_table [index+3].name, index + 4, zone_table [index+4].name);
send_to_char (tmp, ch);
}
return;
case 's': /** shows build summart overall stats **/
numdex = 0;
otop = 0;
mtop = 0;
for ( count_total_rooms = 0, troom = full_room_list;
troom;
troom = troom->lnext, count_total_rooms++ )
if(!(strncmp(troom->description,"No Description Set", 18)) ||
!strncmp(troom->description, " No Description Set", 21) )
numdex++;
for ( objdex = full_object_list; objdex; objdex = objdex->lnext )
if ( !objdex->deleted )
otop++;
for ( chardex = full_mobile_list; chardex; chardex = chardex->mob->lnext )
if ( !chardex->deleted && IS_NPC (chardex) )
mtop++;
for ( chardex = character_list; chardex; chardex = chardex->next ) {
if ( chardex->deleted )
continue;
if ( IS_NPC (chardex) && IS_SET (chardex->act, ACT_STAYPUT) )
stayput++;
}
for ( craft = crafts; craft; craft = craft->next )
craft_tot++;
mysql_safe_query ("SELECT count(name) from %s.pfiles", PFILES_DATABASE);
result = mysql_store_result (database);
if ( result ) {
row = mysql_fetch_row (result);
if ( row )
chars = strtol(row[0], NULL, 10);
mysql_free_result (result);
result = NULL;
}
mysql_safe_query ("SELECT count(username) from forum_users");
result = mysql_store_result (database);
if ( result ) {
row = mysql_fetch_row (result);
if ( row )
accounts = strtol(row[0], NULL, 10);
mysql_free_result (result);
result = NULL;
}
mysql_safe_query ("SELECT count(*) from player_writing");
result = mysql_store_result (database);
if ( result ) {
row = mysql_fetch_row (result);
if ( row )
docs = strtol(row[0], NULL, 10);
mysql_free_result (result);
result = NULL;
}
snprintf(tmp, MAX_STRING_LENGTH,
"\n Described Rooms: %-5d\n"
" Total Rooms: %-5d\n"
" Total Mobiles: %-5d\n"
" Total Objects: %-5d\n"
" Total Crafts: %-5d\n\n"
" Total Characters: %-5d\n"
" Total Accounts: %-5d\n"
" Player Writings: %-5d\n\n"
" Stayput Mobiles: %-5d\n",
count_total_rooms-numdex, count_total_rooms, mtop, otop, craft_tot, chars, accounts, docs, stayput);
send_to_char(tmp, ch);
return;
default:
send_to_char("Not a valid show option.\n",ch);
return;
}
}
void do_zname (CHAR_DATA *ch, char *argument, int cmd)
{
char buf [MAX_STRING_LENGTH];
while ( isspace (*argument) )
argument++;
snprintf (buf, MAX_STRING_LENGTH, "zset %d name %s", ch->room->zone, argument);
command_interpreter (ch, buf);
}
void do_rlink(CHAR_DATA *ch, char *argument, int cmd)
{
char buf1 [MAX_INPUT_LENGTH];
char buf2 [MAX_INPUT_LENGTH];
int dir;
int cha_rnum;
ROOM_DATA *troom;
argument = one_argument (argument, buf1);
argument = one_argument (argument, buf2);
if ( !*buf2 ) {
send_to_char ("Syntax: rlink <direction> <room-number>\n", ch);
return;
}
switch ( *buf1 ) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
cha_rnum = ch->in_room;
if ( !(troom = vtor (strtol(buf2, NULL, 10))) ) {
send_to_char("No room exists with that number.\n", ch);
return;
}
if ( vtor (ch->in_room)->dir_option[dir] )
vtor (vtor (ch->in_room)->dir_option[dir]->to_room)->dir_option[rev_dir[dir]] = 0;
CREATE (vtor (cha_rnum)->dir_option [dir], struct room_direction_data, 1);
vtor (cha_rnum)->dir_option[dir]->general_description = 0;
vtor (cha_rnum)->dir_option[dir]->keyword = 0;
vtor (cha_rnum)->dir_option[dir]->exit_info = 0;
vtor (cha_rnum)->dir_option[dir]->key = -1;
vtor (cha_rnum)->dir_option[dir]->to_room = troom->virtual;
CREATE(troom->dir_option[rev_dir[dir]], struct room_direction_data, 1);
troom->dir_option[rev_dir[dir]]->general_description = 0;
troom->dir_option[rev_dir[dir]]->keyword = 0;
troom->dir_option[rev_dir[dir]]->exit_info = 0;
troom->dir_option[rev_dir[dir]]->key = -1;
troom->dir_option[rev_dir[dir]]->to_room = cha_rnum;
send_to_char("Done.\n", ch);
}
void do_rcret(CHAR_DATA *ch, char *argument, int cmd)
{
char buf1[80], buf2[80];
int dir, dif;
struct secret *r_secret;
half_chop(argument,buf1,buf2);
if(!*buf2) {
send_to_char("Usage: rcret <dir> <difficulty>\n",ch);
return;
}
dif=strtol(buf2, NULL, 10);
switch (*buf1) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
if ( vtor (ch->in_room)->secrets[dir]) {
send_to_char("The old secret description was: \n\n", ch);
send_to_char(vtor (ch->in_room)->secrets[dir]->stext, ch);
r_secret=vtor (ch->in_room)->secrets[dir];
} else {
CREATE(r_secret,struct secret,1);
}
r_secret->diff=dif;
vtor (ch->in_room)->secrets[dir]=r_secret;
make_quiet(ch);
send_to_char("Enter a new secret description. Terminate with an '@'\n", ch);
ch->desc->str = &r_secret->stext;
r_secret->stext=0;
ch->desc->max_str = 2000;
send_to_char("Done.\n", ch);
}
void do_rexit(CHAR_DATA *ch, char *argument, int cmd)
{
char buf1 [MAX_INPUT_LENGTH];
char buf2 [MAX_INPUT_LENGTH];
int dir;
int cha_rnum;
ROOM_DATA *troom;
half_chop(argument, buf1, buf2);
if(!strcmp(buf2,"")) {
send_to_char("No room specified...aborting...\n",ch);
return;
}
switch (*buf1) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
cha_rnum = ch->in_room;
if ( !(troom = vtor (strtol(buf2, NULL, 10))) ) {
send_to_char("No room exists with that number.\n", ch);
return;
}
if ( !vtor (ch->in_room)->dir_option[dir])
CREATE (vtor (cha_rnum)->dir_option[dir], struct room_direction_data,1);
vtor (cha_rnum)->dir_option[dir]->general_description = 0;
vtor (cha_rnum)->dir_option[dir]->keyword = 0;
vtor (cha_rnum)->dir_option[dir]->exit_info = 0;
vtor (cha_rnum)->dir_option[dir]->key = -1;
vtor (cha_rnum)->dir_option[dir]->to_room = troom->virtual;
send_to_char("Done.\n", ch);
}
void do_rname(CHAR_DATA *ch, char *argument, int cmd)
{
for (; isspace(*argument); argument++); /* Get rid of whitespaces */
vtor (ch->in_room)->name = add_hash(argument);
send_to_char("Done.\n", ch);
}
void do_rinit(CHAR_DATA *ch, char *argument, int cmd)
{
int dir = -1;
int virt_nr;
int i, j;
ROOM_DATA *troom;
char arg1 [MAX_INPUT_LENGTH];
char buf [MAX_STRING_LENGTH];
argument = one_argument(argument, arg1);
if (!*arg1) {
send_to_char("You must supply a new room number, or 'n' to use the next available slot.\n", ch);
return;
}
virt_nr = strtol(arg1, NULL, 10);
if (!isdigit(*arg1) && *arg1 != 'n' ) {
send_to_char("The argument must be a digit, or 'n' to use the next available slot.\n", ch);
return;
} else if ( vtor (virt_nr) && *arg1 != 'n' ) {
send_to_char("That room number already exists.\n",ch);
return;
}
else if ( *arg1 == 'n' ) {
for ( i = ch->room->zone * 1000; i <= ch->room->zone * 1000 + 999; i++ )
if ( !vtor(i) )
break;
virt_nr = i;
}
if (virt_nr > ROOM_MAX) {
snprintf (buf, MAX_STRING_LENGTH, "Room numbers cannot exceed %d, You need to recompile "
"and increase ROOM_MAX", ROOM_MAX);
send_to_char(buf,ch);
return;
}
argument = one_argument (argument, buf);
if ( *buf )
dir = index_lookup (dirs, buf);
troom = allocate_room (virt_nr);
troom->virtual = virt_nr;
troom->contents = NULL;
troom->people = NULL;
troom->light = 0; /* Zero light sources */
troom->zone = virt_nr / ZONE_SIZE;
troom->name = add_hash ("New Room");
troom->description = add_hash ("No Description Set.\n");
troom->ex_description = NULL;
troom->wdesc = NULL;
troom->extra = NULL;
for(j=0;j<6;j++)
troom->dir_option[j] = 0;
if ( dir != -1 ) {
snprintf (buf, MAX_STRING_LENGTH, "%s %d", dirs [dir], troom->virtual);
do_rlink (ch, buf, 0);
} else {
snprintf (buf, MAX_STRING_LENGTH, "Room %d has been initialized.\n", virt_nr);
send_to_char(buf, ch);
}
}
void do_rxchange(CHAR_DATA *ch, char *argument, int cmd)
{
char arg1 [MAX_STRING_LENGTH], arg2[MAX_STRING_LENGTH], *result;
char *tail, *end;
int i=0, j=0,k=0;
half_chop(argument,arg1,arg2);
if(!(tail=strstr(ch->room->description,arg1))) {
send_to_char("Old string not found.\n",ch);
return;
}
i=strlen (ch->room->description);
j=strlen (tail);
end = (tail+=strlen(arg1));
k=strlen(end);
if(!arg2[0]) {
CREATE(result,char,i+j+k);
strncpy(result, ch->room->description,(i-j));
strcat(result,arg2);
strcat(result,end+1);
} else {
CREATE(result,char,i+j+k+1);
strncpy(result, ch->room->description,(i-j));
strcat(result,arg2);
strcat(result,end);
}
mem_free (ch->room->description);
ch->room->description = NULL;
ch->room->description = add_hash(result);
}
void post_rdesc (DESCRIPTOR_DATA *d)
{
CHAR_DATA *ch;
ROOM_DATA *room;
ch = d->character;
room = vtor (ch->delay_info1);
ch->delay_info1 = 0;
if ( !*d->pending_message->message ) {
send_to_char ("No room description posted.\n", ch);
return;
}
room->description = add_hash(d->pending_message->message);
d->pending_message = NULL;
}
void do_rdesc(CHAR_DATA *ch, char *argument, int cmd)
{
char buf [MAX_STRING_LENGTH];
ROOM_DATA *room;
room = ch->room;
argument = one_argument (argument, buf);
if ( !str_cmp (buf, "reformat") ) {
reformat_desc (ch->room->description, &ch->room->description);
send_to_char (ch->room->description, ch);
return;
}
if ( *buf ) {
send_to_char ("The only valid parameter to rdesc is 'reformat'.\n",
ch);
return;
}
if ( room->description ) {
send_to_char("The old description was: \n", ch);
send_to_char(room->description, ch);
}
act ("$n begins editing a room description.", FALSE, ch, 0, 0, TO_ROOM);
CREATE (ch->desc->pending_message, MESSAGE_DATA, 1);
ch->desc->str = &ch->desc->pending_message->message;
ch->desc->max_str = MAX_STRING_LENGTH;
ch->delay_info1 = room->virtual;
send_to_char ("Please enter the new description; terminate with an '@'\n\n", ch);
send_to_char ("1-------10--------20--------30--------40--------50--------60---65\n", ch);
make_quiet (ch);
TOGGLE (room->room_flags, ROOM_OK);
ch->desc->proc = post_rdesc;
}
void do_rappend(CHAR_DATA *ch, char *argument, int cmd)
{
char *new;
CREATE(new,char,strlen(vtor (ch->in_room)->description)+1);
strcpy(new,vtor (ch->in_room)->description);
vtor (ch->in_room)->description = new;
if (vtor (ch->in_room)->description) {
send_to_char("The old description was: \n", ch);
send_to_char(vtor (ch->in_room)->description, ch);
}
send_to_char("\nEnter a your additions. Terminate with an '@'\n", ch);
send_to_char ("1-------10--------20--------30--------40--------50--------60---65\n", ch);
make_quiet(ch);
ch->desc->str = &(vtor (ch->in_room)->description);
ch->desc->max_str = 2000;
}
void do_redesc(CHAR_DATA *ch, char *argument, int cmd)
{
struct extra_descr_data *tmp = NULL;
struct extra_descr_data *newdesc = NULL;
struct extra_descr_data *testdesc = NULL;
struct extra_descr_data *delete_desc = NULL;
char buf[256];
argument = one_argument(argument, buf);
for (; isspace(*argument); argument++); /* Get rid of whitespaces */
if(!*buf) {
send_to_char("No argument specified....aborting...\n",ch);
return;
}
for (tmp = vtor (ch->in_room)->ex_description; tmp; tmp = tmp->next) {
if (!cmp_strn(tmp->keyword, buf, strlen(buf))) {
break;
}
}
if ( !str_cmp (argument, "reformat") ) {
reformat_desc (tmp->description, &tmp->description);
send_to_char (tmp->description, ch);
return;
}
if (!tmp) {
CREATE(newdesc,struct extra_descr_data,1);
newdesc->description = '\0';
newdesc->next = vtor (ch->in_room)->ex_description;
newdesc->keyword = add_hash(buf);
vtor (ch->in_room)->ex_description = newdesc;
} else {
send_to_char("The old description was: \n\n", ch);
send_to_char(vtor (ch->in_room)->ex_description->description, ch);
newdesc = tmp;
}
ch->desc->str = &newdesc->description;
send_to_char("Enter a new description. Terminate with an '@'\n", ch);
send_to_char ("1-------10--------20--------30--------40--------50--------60---65\n", ch);
make_quiet(ch);
newdesc->description = 0;
ch->desc->max_str = 2000;
}
void do_rlinkrm(CHAR_DATA *ch, char *argument, int cmd)
{
char buf[256];
int dir;
int cha_rnum, old_rnum;
(void)one_argument(argument, buf);
switch (*buf) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
cha_rnum = ch->in_room;
if (vtor (ch->in_room)->dir_option[dir]) {
old_rnum = vtor (ch->in_room)->dir_option[dir]->to_room;
} else {
send_to_char("There is no exit in that direction.\n", ch);
return;
}
vtor (cha_rnum)->dir_option[dir] = 0;
vtor (old_rnum)->dir_option[rev_dir[dir]] = 0;
send_to_char("Done.\n", ch);
}
void do_rexitrm(CHAR_DATA *ch, char *argument, int cmd)
{
char buf[256];
int dir;
int cha_rnum;
(void)one_argument(argument, buf);
switch (*buf) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
cha_rnum = ch->in_room;
vtor (cha_rnum)->dir_option[dir] = 0;
send_to_char("Done.\n", ch);
}
void do_wsave(CHAR_DATA *ch, char *argument, int cmd)
{
send_to_char ("This command has been disabled. Please use 'zsave all'.\n", ch);
return;
}
void do_rsector(CHAR_DATA *ch, char *argument, int cmd)
{
int flag, no=1, i;
char buf[256], buf2[512], buf3[512];
(void)one_argument(argument, buf);
if(!strcmp(buf,"")) {
snprintf (buf3, MAX_STRING_LENGTH, "Current sector type: %s\n", sector_types[vtor (ch->in_room)->sector_type]);
send_to_char(buf3,ch);
return;
}
if(buf[0]=='?') {
snprintf (buf2, MAX_STRING_LENGTH, "The following sector types are available:\n\t\t\t");
for(i=0; *sector_types[i]!='\n'; i++) {
snprintf( buf2 + strlen(buf2), MAX_STRING_LENGTH, "%-10s ",sector_types[i]);
if(!(no%4)) (strcat(buf2,"\n\t\t\t"));
no++;
}
strcat(buf2,"\n");
send_to_char(buf2,ch);
return;
}
flag = index_lookup (sector_types, buf);
ch->room->sector_type = flag;
send_to_char("Done.\n", ch);
}
void do_rflags (CHAR_DATA *ch, char *argument, int cmd)
{
ROOM_DATA *room;
int flag;
int no = 1;
int i;
char buf [256];
char buf2 [512];
char buf3 [512];
argument = one_argument (argument, buf);
if ( !*buf ) {
sprintbit (ch->room->room_flags, room_bits, buf2);
snprintf (buf3, MAX_STRING_LENGTH, "Current room flags: %s\n", buf2);
send_to_char (buf3, ch);
return;
}
if ( !str_cmp (buf, "mudwide") && !str_cmp (ch->tname, IMPLEMENTOR_ACCOUNT) ) {
argument = one_argument (argument, buf2);
if ( !*buf2 ) {
send_to_char ("Which room flag did you wish to toggle, MUD-wide?\n", ch);
return;
}
if ( (flag = index_lookup (room_bits, buf2)) == -1 ) {
send_to_char ("No such room flag or deity.\n", ch);
return;
}
argument = one_argument (argument, buf2);
if ( str_cmp (buf2, "on") && str_cmp (buf2, "off") ) {
send_to_char ("Did you wish to toggle that flag ON or OFF?\n", ch);
return;
}
for ( room = full_room_list; room; room = room->lnext ) {
if ( IS_SET (room->room_flags, (1 << flag)) && !str_cmp (buf2, "off") )
REMOVE_BIT (room->room_flags, 1 << flag);
else if ( !IS_SET (room->room_flags, (1 << flag)) && !str_cmp (buf2, "on") )
SET_BIT (room->room_flags, 1 << flag);
}
send_to_char ("Done.\n", ch);
return;
}
if ( buf [0] == '?' ) {
snprintf (buf2, MAX_STRING_LENGTH, "The following room flags are available:\n\t\t\t");
for(i=0;*room_bits[i]!='\n';i++) {
snprintf (buf2 + strlen(buf2), MAX_STRING_LENGTH, "%-10s ", room_bits[i]);
if(!(no%4)) (strcat(buf2,"\n\t\t\t"));
no++;
}
strcat(buf2,"\n");
send_to_char(buf2,ch);
send_to_char ("\nYou may also specify a church name too.\n", ch);
return;
}
if ( (i = index_lookup (deity_name, buf)) != -1 ) {
ch->room->deity = i;
send_to_char ("Deity set.\n", ch);
return;
}
if ( (flag = index_lookup (room_bits, buf)) == -1 ) {
send_to_char ("No such room flag or deity.\n", ch);
return;
}
if ( !str_cmp(buf, "OOC") && GET_TRUST(ch) != 5 ) {
send_to_char ("Only a level 5 admin can set the OOC bit.\n", ch);
return;
}
if ( !str_cmp (buf, "psave") ) {
send_to_char ("This flag cannot be toggled.\n", ch);
return;
}
if ( !IS_SET (ch->room->room_flags, (1 << flag)) )
SET_BIT (ch->room->room_flags, (1 << flag));
else
REMOVE_BIT (ch->room->room_flags, (1 << flag));
send_to_char("Flag (re)set.\n", ch);
}
void do_rddesc(CHAR_DATA *ch, char *argument, int cmd)
{
int dir;
char buf[256];
(void)one_argument(argument, buf);
switch (*buf) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default: dir = -1; break;
}
if (dir == -1) {
send_to_char("What direction is that?\n", ch);
return;
}
if(!vtor (ch->in_room)->dir_option[dir]) {
send_to_char("No room exists in that direction.\n",ch);
return;
}
if (vtor (ch->in_room)->dir_option[dir]->general_description) {
send_to_char("The old description was: \n", ch);
send_to_char(vtor (ch->in_room)->dir_option[dir]->general_description, ch);
}
send_to_char("\nEnter a new description. Terminate with an '@'\n", ch);
send_to_char ("1-------10--------20--------30--------40--------50--------60---65\n", ch);
make_quiet(ch);
ch->desc->str = &(vtor (ch->in_room)->dir_option[dir]->general_description);
vtor (ch->in_room)->dir_option[dir]->general_description = 0;
ch->desc->max_str = 2000;
}
void do_rkey(CHAR_DATA *ch, char *argument, int cmd)
{
char buf [MAX_INPUT_LENGTH];
int dir;
ROOM_DATA *room;
argument = one_argument (argument, buf);
switch ( *buf ) {
case 'n': dir = 0; break;
case 'e': dir = 1; break;
case 's': dir = 2; break;
case 'w': dir = 3; break;
case 'u': dir = 4; break;
case 'd': dir = 5; break;
default :
send_to_char("What direction is that?\n", ch);
return;
}
room = vtor (ch->in_room);
if ( !room->dir_option [dir] ) {
send_to_char ("There is no exit in that direction.\n", ch);
return;
}
argument = one_argument (argument, buf);
if ( !isdigit (*buf) ) {
send_to_char ("Syntax: rkey <dir> <key-vnum> [pick-penalty]\n", ch);
return;
}
room->dir_option [dir]->key = strtol(buf, NULL, 10);
*buf = '\0';
argument = one_argument (argument, buf);
if ( isdigit (*buf) )
room->dir_option [dir]->pick_penalty = strtol(buf, NULL, 10);
send_to_char("Done.\n", ch);
}
void do_rdflag (CHAR_DATA *ch, char *argument, int cmd)
{
int dir;
int ind;
ROOM_DIRECTION_DATA *exit_room;
char buf [MAX_STRING_LENGTH];
argument = one_argument (argument, buf);
if ( !*buf || (dir = index_lookup (dirs, buf)) == -1 ) {
send_to_char ("Use a direction: North, South, East, or West.\n", ch);
return;
}
if ( !(exit_room = ch->room->dir_option [dir]) ) {
send_to_char ("There is no exit in that direction.\n", ch);
return;
}
argument = one_argument (argument, buf);
if ( !*buf ) {
send_to_char ("What flag would you like to set? (see tags "
"exit-bits)\n", ch);
return;
}
if ( (ind = index_lookup (exit_bits, buf)) == -1 ) {
send_to_char ("Unknown door flag (see tags exit-bits)\n", ch);
return;
}
TOGGLE (exit_room->exit_info, 1 << ind);
if ( IS_SET (exit_room->exit_info, 1 << ind) )
snprintf (buf, MAX_STRING_LENGTH, "Flag %s set.\n", exit_bits [ind]);
else
snprintf (buf, MAX_STRING_LENGTH, "Flag %s removed.\n", exit_bits [ind]);
send_to_char (buf, ch);
}
void do_minit (CHAR_DATA *ch, char *argument, int cmd)
{
char arg[80];
char buf [MAX_STRING_LENGTH];
int vnum = 0;
CHAR_DATA *newmob = NULL;
int i = 0;
if ( IS_NPC (ch) ) {
send_to_char ("This is a PC only command.\n", ch);
return;
}
(void)one_argument(argument, arg);
if(!arg) {
send_to_char("You must supply a vnum.\n",ch);
return;
}
if(!isdigit(*arg) && *arg != 'n' ) {
send_to_char("The vnum must be a number, or 'n' to use the next available slot.\n",ch);
return;
}
if ( *arg == 'n' ) {
for ( i = ch->room->zone * 1000; i <= ch->room->zone * 1000 + 999; i++ )
if ( !vtom(i) && i != 0 )
break;
vnum = i;
}
else vnum=atol(arg);
if((vnum<0) || (vnum>99999)) {
send_to_char("Vnum must be between 0 and 99999.\n",ch);
return;
}
if ( vtom (vnum) ) {
send_to_char("That vnum is already in use.\n",ch);
return;
}
newmob = new_char (0); /* MOB */
clear_char (newmob);
newmob->mob->virtual = vnum;
newmob->mob->zone = vnum / ZONE_SIZE;
ch->pc->edit_mob = vnum;
newmob->act = 0;
SET_BIT(newmob->act, ACT_ISNPC);
newmob->name = add_hash ("mob new");
newmob->short_descr = add_hash ("a new mobile");
newmob->speaks = SKILL_SPEAK_WESTRON;
newmob->skills [SKILL_SPEAK_WESTRON] = 100;
newmob->max_hit = 80;
newmob->hit = 80;
newmob->max_move = 80;
newmob->move = 80;
newmob->armor = 0;
newmob->offense = 0;
newmob->mob->damroll = 0;
newmob->str = mob_start_stat;
newmob->dex = mob_start_stat;
newmob->intel = mob_start_stat;
newmob->wil = mob_start_stat;
newmob->aur = mob_start_stat;
newmob->con = mob_start_stat;
newmob->agi = mob_start_stat;
newmob->tmp_str = mob_start_stat;
newmob->tmp_dex = mob_start_stat;
newmob->tmp_intel = mob_start_stat;
newmob->tmp_wil = mob_start_stat;
newmob->tmp_aur = mob_start_stat;
newmob->tmp_con = mob_start_stat;
newmob->tmp_agi = mob_start_stat;
newmob->mob->damnodice = 1;
newmob->mob->damsizedice = 2;
newmob->intoxication = 0;
newmob->hunger = -1;
newmob->thirst = -1;
newmob->equip = NULL;
open_skill (newmob, SKILL_PARRY);
open_skill (newmob, SKILL_BLOCK);
open_skill (newmob, SKILL_DODGE);
open_skill (newmob, SKILL_BRAWLING);
fix_offense (newmob);
newmob->natural_delay = 24;
newmob->fight_mode = 2;
newmob->speed = SPEED_WALK;
newmob->clans = str_dup (""); /* Null clan list */
add_mob_to_hash (newmob);
act ("$n creates a new mobile.\n", TRUE, ch, 0, 0, TO_ROOM);
snprintf (buf, MAX_STRING_LENGTH, "Mobile %d has been initialized.\n", vnum);
send_to_char(buf, ch);
}
void do_oinit (CHAR_DATA *ch, char *argument, int cmd)
{
char arg [MAX_STRING_LENGTH];
char arg2 [MAX_STRING_LENGTH];
char buf [MAX_STRING_LENGTH];
int vnum;
int type;
int num = 1;
int i;
OBJ_DATA *newobj;
arg_splitter (2, argument, arg, arg2);
if( !arg ) {
send_to_char ("You must supply a vnum.\n", ch);
return;
}
if ( arg [0] == '?' ) {
snprintf (buf, MAX_STRING_LENGTH, "The following item types are available:\n");
for ( type = 0; *item_types [type] != '\n'; type++) {
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-20s", item_types [type]);
if ( !(num % 4) )
strcat (buf, "\n");
num++;
}
strcat (buf, "\n");
send_to_char (buf, ch);
return;
}
if ( !isdigit (*arg) && *arg != 'n' ) {
send_to_char ("The vnum must be a number, or 'n' to use the next available slot.\n", ch);
return;
}
if ( *arg == 'n' ) {
for ( i = ch->room->zone * 1000; i <= ch->room->zone * 1000 + 999; i++ )
if ( !vtoo(i) && i != 0 )
break;
vnum = i;
}
else
vnum=atol(arg);
if ( vnum == 0 ) {
send_to_char ("Object 0 must NEVER be used.\n", ch);
return;
}
if ( (vnum < 1) || (vnum > 99999) ) {
send_to_char ("Vnum must be between 1 and 99999.\n", ch);
return;
}
if ( vnum == VNUM_TICKET ) {
send_to_char ("That vnum is reserved for ticket use.\n", ch);
return;
}
if ( vtoo (vnum) ) {
send_to_char ("That vnum is already in use.\n", ch);
return;
}
type = index_lookup (item_types, arg2);
if(type == -1) {
send_to_char("Not a valid type.\n",ch);
return;
}
newobj = new_object ();
clear_object (newobj);
newobj->virtual = vnum;
newobj->zone = vnum / ZONE_SIZE;
add_obj_to_hash (newobj);
ch->pc->edit_obj = vnum;
newobj->full_description = 0;
newobj->contains = 0;
newobj->in_room = NOWHERE;
newobj->in_obj = 0;
newobj->next_content = 0;
newobj->carried_by = 0;
newobj->full_description = str_dup ("");
newobj->obj_flags.type_flag = index_lookup (item_types, arg2);
switch (type) {
case ITEM_FLUID:
newobj->name = add_hash ("water");
newobj->short_description = add_hash ("filled with water");
newobj->description = add_hash ("");
newobj->obj_flags.weight = 100;
break;
case ITEM_LIQUID_FUEL:
newobj->name = add_hash ("oil");
newobj->short_description = add_hash ("filled with oil");
newobj->description = add_hash ("");
newobj->obj_flags.weight = 100;
break;
case ITEM_TENT :
newobj->name = add_hash("tent");
newobj->short_description = add_hash ("a worn tent");
newobj->description = add_hash ("an old, worn tent");
SET_BIT (newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[2] = 1;
newobj->o.od.value[3] = -1;
newobj->obj_flags.weight = 1500;
break;
case ITEM_DWELLING :
newobj->name = add_hash("shelter");
newobj->short_description = add_hash ("a hastily-constructed shelter");
newobj->description = add_hash ("a very crudely and hastily constructed shelter");
newobj->o.od.value[2] = 1;
newobj->o.od.value[3] = -1;
newobj->obj_flags.weight = 1500;
break;
case ITEM_LIGHT :
newobj->name = add_hash("lantern");
newobj->short_description = add_hash("a brass lantern");
newobj->description = add_hash("an old dented lantern");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[2] = 20;
newobj->obj_flags.weight = 500;
break;
case ITEM_WEAPON :
newobj->name = add_hash("sword");
newobj->short_description = add_hash("a long sword");
newobj->description = add_hash("a gleaming long sword");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
SET_BIT(newobj->obj_flags.wear_flags, ITEM_WIELD);
newobj->o.od.value[1] = 2;
newobj->o.od.value[2] = 4;
newobj->o.od.value[3] = 3;
newobj->obj_flags.weight = 700;
break;
case ITEM_ARMOR :
newobj->name = add_hash("jacket");
newobj->short_description = add_hash("a leather jacket");
newobj->description = add_hash("a heavy leather jacket");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
SET_BIT(newobj->obj_flags.wear_flags, ITEM_WEAR_BODY);
newobj->o.od.value[0] = 2;
newobj->obj_flags.weight = 700;
break;
case ITEM_KEY :
newobj->name = add_hash("key");
newobj->short_description = add_hash("a key");
newobj->description = add_hash("a small silver key");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 0;
newobj->obj_flags.weight = 100;
break;
case ITEM_DRINKCON :
newobj->name = add_hash("skin");
newobj->short_description = add_hash("a water skin");
newobj->description = add_hash("a leaky skin lies here.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 10;
newobj->o.od.value[1] = 0;
newobj->o.od.value[2] = ITEM_FLUID;
newobj->o.od.value[3] = 0;
newobj->obj_flags.weight = 200;
break;
case ITEM_FOOD :
newobj->name = add_hash("bread");
newobj->short_description = add_hash("a loaf of bread");
newobj->description = add_hash("a loaf of bread");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 6;
newobj->o.od.value[3] = 0;
newobj->obj_flags.weight = 300;
break;
case ITEM_CONTAINER :
newobj->name = add_hash("bag");
newobj->short_description = add_hash("a rather large bag");
newobj->description = add_hash("a large brown bag lies here");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 100;
newobj->o.od.value[1] = 0;
newobj->o.od.value[2] = -1;
newobj->obj_flags.weight = 300;
break;
case ITEM_BOARD :
newobj->name = add_hash("board");
newobj->short_description = add_hash("a board");
newobj->description = add_hash("a bulletin board is standing here.");
newobj->o.od.value[2] = 1;
newobj->obj_flags.weight = 100;
break;
case ITEM_USURY_NOTE :
newobj->name = add_hash("note usury");
newobj->short_description = add_hash("a usury note");
newobj->description = add_hash("A usury note lies on the floor.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 1;
newobj->o.od.value[1] = 1;
newobj->o.od.value[2] = 20;
newobj->o.od.value[3] = 40;
newobj->obj_flags.weight = 100;
break;
case ITEM_BULLET:
newobj->name = add_hash ("bullet sphere small crude iron");
newobj->short_description = add_hash ("a crude iron sling bullet");
newobj->description = add_hash ("A small sphere of crudely-wrought iron has been left here.");
SET_BIT (newobj->obj_flags.extra_flags, ITEM_STACK);
SET_BIT (newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->obj_flags.weight = 10;
newobj->o.od.value[0] = 1;
newobj->o.od.value[1] = 4;
newobj->quality = 30;
break;
case ITEM_MISSILE:
newobj->name = add_hash ("arrow iron-tipped ash-shafted flight");
newobj->short_description = add_hash ("an iron-tipped, ash-shafted flight arrow");
newobj->description = add_hash ("An arrow has been left here.");
SET_BIT (newobj->obj_flags.extra_flags, ITEM_STACK);
SET_BIT (newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->obj_flags.weight = 10;
newobj->o.od.value[0] = 1;
newobj->o.od.value[1] = 6;
newobj->quality = 30;
break;
case ITEM_SHEATH:
newobj->name = add_hash ("sheath brown leather");
newobj->short_description = add_hash ("a brown leather sheath");
newobj->description = add_hash ("A brown leather sheath has been left here.");
SET_BIT (newobj->obj_flags.wear_flags, ITEM_TAKE);
SET_BIT (newobj->obj_flags.wear_flags, ITEM_WEAR_BELT);
newobj->o.od.value[0] = 800;
newobj->quality = 30;
newobj->obj_flags.weight = 200;
break;
case ITEM_KEYRING:
newobj->name = add_hash ("keyring sturdy iron");
newobj->short_description = add_hash ("a sturdy iron keyring");
newobj->description = add_hash ("A sturdy iron keyring lies here, forgotten.");
SET_BIT (newobj->obj_flags.wear_flags, ITEM_TAKE);
SET_BIT (newobj->obj_flags.wear_flags, ITEM_WEAR_BELT);
newobj->o.od.value[0] = 10;
newobj->quality = 30;
newobj->obj_flags.weight = 50;
break;
case ITEM_QUIVER:
newobj->name = add_hash ("quiver brown leather");
newobj->short_description = add_hash ("a brown leather quiver");
newobj->description = add_hash ("A brown leather quiver lies here.");
SET_BIT (newobj->obj_flags.wear_flags, ITEM_TAKE);
SET_BIT (newobj->obj_flags.wear_flags, ITEM_WEAR_SHOULDER);
newobj->o.od.value[0] = 25;
newobj->quality = 30;
newobj->obj_flags.weight = 200;
break;
case ITEM_INK:
newobj->name = add_hash("ink black pot ceramic small");
newobj->short_description = add_hash ("a small ceramic pot of black ink");
newobj->description = add_hash("A small ceramic pot has been left here.");
newobj->ink_color = add_hash ("black ink");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 10;
newobj->o.od.value[1] = 10;
newobj->obj_flags.weight = 200;
break;
case ITEM_BOOK:
newobj->name = add_hash("tome leather-bound small");
newobj->short_description = add_hash ("a small, leather-bound tome");
newobj->description = add_hash("A small tome has been left here.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 25;
newobj->obj_flags.weight = 500;
break;
case ITEM_PARCHMENT:
newobj->name = add_hash("paper parchment sheet");
newobj->short_description = add_hash ("a sheet of parchment");
newobj->description = add_hash("A sheet of parchment has been discarded here.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 0;
newobj->obj_flags.weight = 10;
break;
case ITEM_WRITING_INST:
newobj->name = add_hash("quill writing");
newobj->short_description = add_hash ("a writing quill");
newobj->description = add_hash("A writing quill has been discarded here.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 0;
newobj->obj_flags.weight = 25;
break;
case ITEM_HEALER_KIT:
newobj->name = add_hash("kit healer");
newobj->short_description = add_hash ("a healer's kit");
newobj->description = add_hash("A healer's kit lies on the floor.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 0;
newobj->obj_flags.weight = 500;
break;
case ITEM_REPAIR_KIT:
newobj->name = add_hash("kit repair mending");
newobj->short_description = add_hash ("a repair kit");
newobj->description = add_hash("A repair kit lies on the floor.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE | ITEM_WEAR_BELT);
newobj->o.od.value[0] = 0;
newobj->obj_flags.weight = 500;
break;
default:
act ("Generic object created.", FALSE, ch, 0, 0, TO_CHAR);
newobj->name = add_hash("object generic");
newobj->short_description = add_hash ("a generic object");
newobj->description = add_hash("Some careless admin has left a generic object here.");
SET_BIT(newobj->obj_flags.wear_flags, ITEM_TAKE);
newobj->o.od.value[0] = 0;
newobj->obj_flags.weight = 100;
return;
break;
}
if ( IS_SET (newobj->obj_flags.extra_flags, ITEM_MAGIC) )
REMOVE_BIT (newobj->obj_flags.extra_flags, ITEM_MAGIC);
if ( IS_SET (newobj->obj_flags.extra_flags, ITEM_INVISIBLE) )
REMOVE_BIT (newobj->obj_flags.extra_flags, ITEM_INVISIBLE);
if ( GET_TRUST (ch) < 5 )
SET_BIT (newobj->obj_flags.extra_flags, index_lookup (extra_bits, "ok"));
newobj = load_object (vnum);
obj_to_char (newobj, ch);
act ("$n does a little creatin'.\n", TRUE, ch, 0, 0, TO_ROOM);
send_to_char ("Done.\n", ch);
}
void do_rblock(CHAR_DATA *ch, char *argument, int cmd)
{
ROOM_DATA *troom;
char arg1[80], arg2[80], arg3[80];
int zone, width, height, bfree, used=0;
*s_buf='\0';
arg_splitter(3,argument,arg1,arg2,arg3);
zone=strtol(arg1, NULL, 10);
width=strtol(arg2, NULL, 10);
height=strtol(arg3, NULL, 10);
for ( troom = full_room_list; troom; troom = troom->lnext ) {
if ( troom->zone == zone)
used++;
}
bfree = (ZONE_SIZE-used);
snprintf (s_buf, MAX_STRING_LENGTH, "bfree:%d\n",bfree);
send_to_char(s_buf,ch);
if(bfree<(width*height)) {
send_to_char("Not enough free rooms for block.\n",ch);
return;
}
}
void do_runused (CHAR_DATA *ch, char *argument, int cmd)
{
int unused [ZONE_SIZE];
int zone;
int line_entry;
int i;
char buf [MAX_STRING_LENGTH];
ROOM_DATA *room;
argument = one_argument (argument, buf);
if ( !*buf )
zone = vtor (ch->in_room)->zone;
else if ( !just_a_number (buf) ||
strtol(buf, NULL, 10) < 0 ||
strtol(buf, NULL, 10) >= MAX_ZONE ) {
send_to_char ("Syntax: runused [zone #]\n", ch);
return;
}
else
zone = strtol(buf, NULL, 10);
for ( i = 0; i < ZONE_SIZE; i++ )
unused [i] = 0;
for ( room = full_room_list; room; room = room->lnext )
if ( room->zone == zone )
unused [room->virtual % ZONE_SIZE] = 1;
snprintf (buf, MAX_STRING_LENGTH, " ");
for ( i = 0, line_entry = -2; i < ZONE_SIZE; i++ ) {
if ( unused [i] )
continue;
line_entry = (line_entry + 1) % 12;
if ( line_entry == 11 )
strcat (buf, "\n ");
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-4d ", i + ZONE_SIZE * zone);
}
strcat (buf, "\n");
page_string (ch->desc, buf);
}
void do_munused(CHAR_DATA *ch,char *argument,int cmd)
{
int unused [ZONE_SIZE];
int zone;
int line_entry;
int i;
char buf [MAX_STRING_LENGTH];
CHAR_DATA *mob;
argument = one_argument (argument, buf);
if ( !*buf )
zone = vtor (ch->in_room)->zone;
else if ( !just_a_number (buf) ||
strtol(buf, NULL, 10) < 0 ||
strtol(buf, NULL, 10) >= MAX_ZONE ) {
send_to_char ("Syntax: munused [zone #]\n", ch);
return;
}
else
zone = strtol(buf, NULL, 10);
for ( i = 0; i < ZONE_SIZE; i++ )
unused [i] = 0;
for ( mob = full_mobile_list; mob; mob = mob->mob->lnext )
if ( mob->mob->virtual / ZONE_SIZE == zone )
unused [mob->mob->virtual % ZONE_SIZE] = 1;
snprintf (buf, MAX_STRING_LENGTH, " ");
for ( i = 0, line_entry = -2; i < ZONE_SIZE; i++ ) {
if ( unused [i] )
continue;
line_entry = (line_entry + 1) % 12;
if ( line_entry == 11 )
strcat (buf, "\n ");
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-4d ", i + ZONE_SIZE * zone);
}
strcat (buf, "\n");
page_string (ch->desc, buf);
}
void do_ounused (CHAR_DATA *ch, char *argument, int cmd)
{
int unused [ZONE_SIZE];
int zone;
int line_entry;
int i;
char buf [MAX_STRING_LENGTH];
OBJ_DATA *obj;
argument = one_argument (argument, buf);
if ( !*buf )
zone = vtor (ch->in_room)->zone;
else if ( !just_a_number (buf) ||
strtol(buf, NULL, 10) < 0 ||
strtol(buf, NULL, 10) >= MAX_ZONE ) {
send_to_char ("Syntax: runused [zone #]\n", ch);
return;
}
else
zone = strtol(buf, NULL, 10);
for ( i = 0; i < ZONE_SIZE; i++ )
unused [i] = 0;
for ( obj = full_object_list; obj; obj = obj->lnext )
if ( obj->zone == zone )
unused [obj->virtual % ZONE_SIZE] = 1;
snprintf (buf, MAX_STRING_LENGTH, " ");
for ( i = 0, line_entry = -2; i < ZONE_SIZE; i++ ) {
if ( unused [i] )
continue;
line_entry = (line_entry + 1) % 12;
if ( line_entry == 11 )
strcat (buf, "\n ");
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-4d ", i + ZONE_SIZE * zone);
}
strcat (buf, "\n");
page_string (ch->desc, buf);
}
int index_lookup (char **index, char *lookup)
{
int i;
int lenlook;
if (!*lookup)
return -1;
lenlook = strlen (lookup);
for ( i = 0; *index [i] != '\n'; i++ ){
if ( !cmp_strn (index [i], lookup, lenlook))
return i;
}
return -1;
}
int skill_index_lookup (char *lookup)
{
int jdex;
int lenlook;
if (!*lookup)
return -1;
lenlook = strlen (lookup);
for ( jdex = 1; *skill_data[jdex].skill_name != '\n'; jdex++ ){
if ( !cmp_strn (skill_data[jdex].skill_name, lookup, lenlook))
return jdex;
}
return -1;
}
void do_tags (CHAR_DATA *ch, char *argument, int cmd)
{
char tag_name [MAX_INPUT_LENGTH];
char buf [MAX_STRING_LENGTH];
int name_no;
int i;
argument = one_argument (argument, tag_name);
if ( !*tag_name ) {
for ( name_no = 0; *constant_info [name_no].constant_name; name_no++ ) {
snprintf (buf, MAX_STRING_LENGTH, "\t%-20s %s\n",
constant_info [name_no].constant_name,
constant_info [name_no].description);
send_to_char (buf, ch);
}
return;
}
for ( name_no = 0; *constant_info [name_no].constant_name; name_no++ )
if ( !cmp_strn (constant_info [name_no].constant_name, tag_name,
strlen (tag_name)) )
break;
if ( !str_cmp (tag_name, "drinks") ) {
act ("Type 'show o fluid' and set OVAL2 on the drink object to the desired fluid's VNUM.", FALSE, ch, 0, 0, TO_CHAR | TO_ACT_FORMAT);
return;
}
if ( !strcmp (tag_name, "races") || !strcmp (tag_name, "race")){
strcpy (buf, "\t ");
for ( i = 0; i <= MAX_RACE; i++){
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-15s ",
db_race_table[i].name);
if ( !((i + 1) % 4) )
strcat (buf, "\n\t");
}
strcat (buf, "\n");
send_to_char (buf, ch);
return;
}
if ( !strcmp (tag_name, "skills") || !strcmp (tag_name, "skill")){
strcpy (buf, "\t ");
for ( i = 0; i <= LAST_SKILL; i++){
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-15s ",
skill_data[i].skill_name);
if ( !((i + 1) % 4) )
strcat (buf, "\n\t");
}
strcat (buf, "\n");
send_to_char (buf, ch);
return;
}
if ( !*constant_info [name_no].constant_name ) {
send_to_char ("No such tag name, type 'tags' to get a "
"listing.\n", ch);
return;
}
strcpy (buf, "\t");
for ( i = 0; * (char *) constant_info [name_no].index [i] != '\n'; i++ ) {
snprintf (ADDBUF, MAX_STRING_LENGTH, "%-15s ",
(char *) constant_info [name_no].index [i]);
if ( !((i + 1) % 4) )
strcat (buf, "\n\t");
}
strcat (buf, "\n");
send_to_char (buf, ch);
return;
}
void do_object (CHAR_DATA *ch, char *argument, int cmd)
{
char buf [MAX_INPUT_LENGTH];
char buf2 [MAX_INPUT_LENGTH];
OBJ_DATA *edit_object;
if ( IS_NPC (ch) ) {
send_to_char ("Only PCs can use this command.\n", ch);
return;
}
argument = one_argument (argument, buf);
if ( !*buf ) {
if ( ch->pc->edit_obj && vtoo (ch->pc->edit_obj) ) {
(void)one_argument (vtoo(ch->pc->edit_obj)->name, buf2);
snprintf (buf, MAX_STRING_LENGTH, "object %d", ch->pc->edit_obj);
do_stat (ch, buf, 0);
} else
send_to_char ("You're not editing an object.\n", ch);
return;
}
if ( just_a_number (buf) && vtoo (strtol(buf, NULL, 10)) )
edit_object = vtoo (strtol(buf, NULL, 10));
else
if ((edit_object = get_obj_in_list_vis (ch, buf, ch->right_hand)) ||
(edit_object = get_obj_in_list_vis (ch, buf, ch->left_hand)) ||
(edit_object = get_obj_in_list_vis (ch, buf, ch->room->contents)))
/** do nothing in these cases **/;
else {
send_to_char ("Couldn't find that object.\n", ch);
ch->pc->edit_obj = 0;
return;
}
if ( edit_object->virtual == VNUM_TICKET ) {
send_to_char ("Nobody is allowed to edit tickets. Sorry.\n", ch);
ch->pc->edit_obj = 0;
return;
}
ch->pc->edit_obj = edit_object->virtual;
while ( *argument == ' ' )
argument++;
if ( *argument )
do_oset (ch, argument, 0);
snprintf (buf, MAX_STRING_LENGTH, "Editing object %s\n", edit_object->name);
send_to_char (buf, ch);
}
int redefine_objects (OBJ_DATA *proto)
{
int change_count = 0;
OBJ_DATA *obj;
for ( obj = object_list; obj; obj = obj->next ) {
if ( obj->deleted || obj->virtual != proto->virtual )
continue;
if ( GET_ITEM_TYPE (obj) == ITEM_TENT || GET_ITEM_TYPE (obj) == ITEM_DWELLING )
continue;
change_count++;
if ( !IS_SET (obj->obj_flags.extra_flags, ITEM_VARIABLE) )
obj->name = proto->name;
if ( !IS_SET (obj->obj_flags.extra_flags, ITEM_VARIABLE) )
obj->short_description = proto->short_description;
if ( !IS_SET (obj->obj_flags.extra_flags, ITEM_VARIABLE) )
obj->description = proto->description;
if ( !IS_SET (obj->obj_flags.extra_flags, ITEM_VARIABLE) )
obj->full_description = proto->full_description;
if ( !IS_SET (obj->obj_flags.extra_flags, ITEM_VARIABLE) )
obj->obj_flags.extra_flags = proto->obj_flags.extra_flags;
if ( IS_SET(obj->obj_flags.extra_flags, ITEM_VARIABLE) )
insert_string_variables (obj, proto, 0);
else obj->var_color = 0;
obj->obj_flags.type_flag = proto->obj_flags.type_flag;
obj->obj_flags.wear_flags = proto->obj_flags.wear_flags;
obj->o.od.value [0] = proto->o.od.value [0];
if ( GET_ITEM_TYPE (obj) != ITEM_KEY )
obj->o.od.value [1] = proto->o.od.value [1];
obj->o.od.value [2] = proto->o.od.value [2];
obj->o.od.value [3] = proto->o.od.value [3];
obj->o.od.value [4] = proto->o.od.value [4];
obj->o.od.value [5] = proto->o.od.value [5];
obj->quality = proto->quality;
obj->econ_flags = proto->econ_flags;
obj->obj_flags.weight = proto->obj_flags.weight;
obj->obj_flags.cost = proto->obj_flags.cost;
obj->silver = proto->silver;
obj->coppers = proto->coppers;
obj->activation = proto->activation;
obj->wdesc = proto->wdesc;
if ( !obj->equiped_by )
obj->size = proto->size;
SET_BIT (obj->obj_flags.extra_flags, ITEM_NEWSKILLS);
/* obj->xaffected = proto->xaffected; Don't copy these */
}
return change_count;
}
int redefine_mobiles (CHAR_DATA *proto)
{
int i;
int change_count = 0;
CHAR_DATA *mob;
for ( mob = character_list; mob; mob = mob->next ) {
if ( mob->deleted ||
!IS_NPC (mob) ||
mob->mob->virtual != proto->mob->virtual )
continue;
change_count++;
mob->name = proto->name;
mob->short_descr = proto->short_descr;
mob->long_descr = proto->long_descr;
mob->description = proto->description;
mob->act = proto->act;
mob->affected_by = proto->affected_by;
mob->mob->damShowing the first 100 KB of 273.8 KB. Download the archive for the full file.