/***************************************************************************\ [*] ___ ____ ____ __ __ ____ [*] ROGUE: ROM With Attitude [*] [*] /#/ ) /#/ ) /#/ ) /#/ /#/ /#/ [*] All rights reserved [*] [*] /#/ < /#/ / /#/ _ /#/ /#/ /#/-- [*] Copyright(C) 2000-2001 [*] [*] /#/ \(#(__/ (#(__/ (#(__/#/ (#(___ [*] Kenneth Conley (Mendanbar) [*] [*] Expression of Digital Creativity.. [*] scmud@mad.scientist.com [*] [-]---------------------------------------+-+-----------------------------[-] [*] File: pedit.cpp [*] [*] Usage: Pueblo Editor, edit songs and PUEBLO_DIR [*] \***************************************************************************/ /* * I think this will just be a rehack of Erwin's social editor. * The "re" part being I hacked it to work more coherently with Ivan's * OLC awhile back. This should accomplish the same thing, just a little * differently. * * We want to be able to expand the music list without editing a static * table within the code. We also should be able to set local or maybe * even a global URL for the song.. possibly. Then again we might just * leave that to a definition in "pueblo.h" * - Mendanbar (06/29/01) */ #include "merc.h" #include "db.h" #include "tables.h" #include "lookup.h" int maxPSong; struct pmusic_type *pmusic_table; void load_psong(FILE *fp, PMUSIC_DATA *song) { song->name = fread_string(fp); song->fname = fread_string(fp); song->locurl = fread_string(fp); } void load_pmusic_table() { int i; FILE *fp; if (!(fp = fopen(PMUSIC_FILE, "r"))) { mudlogf(BRF, LVL_CODER, TRUE, "Could not open %s for reading.", PMUSIC_FILE); exit(1); } fscanf(fp, "%d\n", &maxPSong); pmusic_table = (PMUSIC_DATA *)malloc(sizeof(struct pmusic_type) * (maxPSong+1)); for (i = 0; i < maxPSong; i++) load_psong(fp, &pmusic_table[i]); pmusic_table[maxPSong].name = str_dup(""); fclose(fp); } void save_psong(const struct pmusic_type *s, FILE *fp) { fprintf(fp, "%s~\n" "%s~\n" "%s~\n\n", s->name ? s->name : "", s->fname ? s->fname : "", s->locurl ? s->locurl : ""); } void save_pmusic_table() { int i; FILE *fp; if (!(fp = fopen(PMUSIC_FILE, "w"))) { mudlogf(BRF, LVL_CODER, TRUE, "Could not open %s for writing.", PMUSIC_FILE); return; } fprintf(fp, "%d\n", maxPSong); for (i = 0; i < maxPSong; i++) save_psong(&pmusic_table[i], fp); fclose(fp); } PMUSIC_DATA *get_pmusic_data(char *name) { int i; for (i = 0; i < maxPSong; i++) if (!str_cmp(name, pmusic_table[i].name)) return &pmusic_table[i]; return NULL; } int pmusic_lookup(const char *name) { int i; for (i = 0; i < maxPSong; i++) if (!str_cmp(name, pmusic_table[i].name)) return i; return -1; }