/************************************************************************** * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. * * * * Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * * * In order to use any part of this Merc Diku Mud, you must comply with * * both the original Diku license in 'license.doc' as well the Merc * * license in 'license.txt'. In particular, you may not remove either of * * these copyright notices. * * * * Much time and thought has gone into this software and you are * * benefiting. We hope that you share your changes too. What goes * * around, comes around. * *************************************************************************** * ROM 2.4 is copyright 1993-1998 Russ Taylor * * ROM has been brought to you by the ROM consortium * * Russ Taylor (rtaylor@hypercube.org) * * Gabrielle Taylor (gtaylor@hypercube.org) * * Brian Moore (zump@rom.org) * * By using this code, you have agreed to follow the terms of the * * ROM license, in the file Rom24/doc/rom.license * *************************************************************************** * 1stMUD ROM Derivative (c) 2001-2002 by Ryan Jennings * * http://1stmud.dlmud.com/ <r-jenn@shaw.ca> * ***************************************************************************/ #include <sys/types.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "merc.h" #include "olc.h" #include "lookup.h" #include "recycle.h" #include "interp.h" #include "tables.h" #define GREDIT(fun) bool fun (CHAR_DATA *ch, const char *argument) GREDIT(gredit_show) { int x; GROUP_DATA *pGroup; EDIT_GROUP(ch, pGroup); chprintln(ch, draw_line(ch, NULL, 0)); chprintlnf(ch, "Name: %s", pGroup->name); chprintln(ch, "Class Ratings:"); for (x = 0; x < maxClass; x++) chprintf(ch, "[%3.3s: %3d] ", class_table[x].name, pGroup->rating[x]); chprintln(ch, ""); chprintln(ch, "Spells:"); for (x = 0; pGroup->spells[x] != NULL; x++) chprintlnf(ch, "%2d) %s", x + 1, pGroup->spells[x]); chprintln(ch, draw_line(ch, NULL, 0)); return TRUE; } GREDIT(gredit_create) { int j, i = maxGroup; int x = 0; GROUP_DATA *pGroup; struct group_type *new_table; char buf[MIL]; CHAR_DATA *pch; if (!IS_NULLSTR(argument) && group_lookup(argument) == -1) sprintf(buf, argument); else sprintf(buf, "New Group%d", maxGroup + 1); maxGroup++; alloc_mem(new_table, struct group_type, maxGroup); if (!new_table) { chprintln(ch, "Memory Allocation Failed!!! Unable to create group."); return FALSE; } for (j = 0; j < i; j++) new_table[j] = group_table[j]; free_mem(group_table); group_table = new_table; group_table[i].name = str_dup(buf); for (x = 0; x < MAX_IN_GROUP; x++) group_table[i].spells[x] = NULL; alloc_mem(group_table[i].rating, int, maxClass); for (pch = player_first; pch; pch = pch->next_player) { realloc_mem(pch->pcdata->group_known, bool, maxGroup); if (pch->gen_data != NULL) realloc_mem(pch->gen_data->group_chosen, bool, maxGroup); } pGroup = &group_table[i]; chprintln(ch, "Group created."); edit_start(ch, pGroup, ED_GROUP); return TRUE; } GREDIT(gredit_ratings) { GROUP_DATA *pGroup; int pClass, value; char arg1[MIL], arg2[MIL]; EDIT_GROUP(ch, pGroup); argument = one_argument(argument, arg1); one_argument(argument, arg2); if (IS_NULLSTR(arg1) || IS_NULLSTR(arg2)) { chprintln(ch, "Syntax: ratings <class-name> <value>"); return FALSE; } if ((pClass = class_lookup(arg1)) == -1) { chprintln(ch, "That is not a valid class."); return FALSE; } if (!is_number(arg2)) { chprintln(ch, "That is not a valid value."); return FALSE; } else value = atoi(arg2); pGroup->rating[pClass] = value; chprintlnf(ch, "%s's rating for %s changed to %d.", pGroup->name, class_table[pClass].name, value); return TRUE; } GREDIT(gredit_spells) { GROUP_DATA *pGroup; int i; bool found = FALSE; EDIT_GROUP(ch, pGroup); if (IS_NULLSTR(argument)) { chprintln(ch, "Syntax: spells <spell-name> - toggles spell name"); return FALSE; } for (i = 0; pGroup->spells[i] != NULL; i++) { if (found) { pGroup->spells[i - 1] = pGroup->spells[i]; pGroup->spells[i] = NULL; continue; } if (!str_cmp(argument, pGroup->spells[i])) { chprintlnf(ch, "%s spell removed.", pGroup->spells[i]); free_string(pGroup->spells[i]); pGroup->spells[i] = NULL; found = TRUE; } } if (found) return TRUE; if (i >= MAX_IN_GROUP) { chprintln(ch, "Too many spells already in group."); return FALSE; } if (skill_lookup(argument) == -1) chprintln(ch, "WARNING: that skill does not exist."); replace_string(pGroup->spells[i], argument); chprintlnf(ch, "%s skill/spell added to %s.", argument, pGroup->name); return TRUE; } GREDIT(gredit_delete) { GROUP_DATA *pGroup; EDIT_GROUP(ch, pGroup); if (str_cmp(argument, "confirm")) { chprintln (ch, "Typing 'delete confirm' will permanetely remove this group!"); return FALSE; } else { int i, j = 0, c; struct group_type *new_table; alloc_mem(new_table, struct group_type, maxGroup); if (!new_table) { chprintln(ch, "Memory Allocation error!!! Unable to delete group."); return FALSE; } c = group_lookup(pGroup->name); for (i = 0; i < maxGroup; i++) if (i != c) new_table[j++] = group_table[i]; free_mem(group_table); group_table = new_table; maxGroup--; pGroup = &group_table[0]; edit_start(ch, pGroup, ED_GROUP); chprintln(ch, "Group deleted."); } return TRUE; } VALIDATE_FUN(validate_groupname) { if (group_lookup((const char *) arg) != -1) { chprintln(ch, "That group already exists."); return FALSE; } return TRUE; }