#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "merc.h"
#include "music.h"
#include "recycle.h"
Include dependency graph for music.c:

Go to the source code of this file.
Functions | |
| void | do_play (CHAR_DATA *ch, char *argument) |
| void | load_songs (void) |
| void | song_update (void) |
Variables | |
| int | channel_songs [MAX_GLOBAL+1] |
| song_data | song_table [MAX_SONGS] |
|
||||||||||||
|
Definition at line 220 of file music.c. References add_buf(), buf_string(), can_see_obj(), capitalize(), channel_songs, room_index_data::contents, FALSE, free_buf(), obj_data::in_room, ITEM_JUKEBOX, obj_data::item_type, MAX_GLOBAL, MAX_INPUT_LENGTH, MAX_SONGS, MAX_STRING_LENGTH, new_buf(), obj_data::next_content, one_argument(), page_to_char(), send_to_char(), obj_data::short_descr, song_table, str_cmp(), str_prefix(), TRUE, and obj_data::value. Referenced by do_examine(). 00221 {
00222 OBJ_DATA *juke;
00223 char *str, arg[MAX_INPUT_LENGTH];
00224 int song, i;
00225 bool global = FALSE;
00226
00227 str = one_argument (argument, arg);
00228
00229 for (juke = ch->in_room->contents; juke != NULL;
00230 juke = juke->next_content) if (juke->item_type == ITEM_JUKEBOX
00231 && can_see_obj (ch, juke))
00232 break;
00233
00234 if (argument[0] == '\0')
00235 {
00236 send_to_char ("Play what?\n\r", ch);
00237 return;
00238 }
00239
00240 if (juke == NULL)
00241 {
00242 send_to_char ("You see nothing to play.\n\r", ch);
00243 return;
00244 }
00245
00246 if (!str_cmp (arg, "list"))
00247 {
00248 BUFFER *buffer;
00249 char buf[MAX_STRING_LENGTH];
00250 int col = 0;
00251 bool artist = FALSE, match = FALSE;
00252
00253 buffer = new_buf ();
00254 argument = str;
00255 argument = one_argument (argument, arg);
00256
00257 if (!str_cmp (arg, "artist"))
00258 artist = TRUE;
00259
00260 if (argument[0] != '\0')
00261 match = TRUE;
00262
00263 sprintf (buf, "%s has the following songs available:\n\r",
00264 juke->short_descr);
00265 add_buf (buffer, capitalize (buf));
00266
00267 for (i = 0; i < MAX_SONGS; i++)
00268 {
00269 if (song_table[i].name == NULL)
00270 break;
00271
00272 if (artist && (!match
00273 || !str_prefix (argument, song_table[i].group)))
00274 sprintf (buf, "%-39s %-39s\n\r",
00275 song_table[i].group, song_table[i].name);
00276 else if (!artist && (!match
00277 || !str_prefix (argument,
00278 song_table[i].name)))
00279 sprintf (buf, "%-35s ", song_table[i].name);
00280 else
00281 continue;
00282 add_buf (buffer, buf);
00283 if (!artist && ++col % 2 == 0)
00284 add_buf (buffer, "\n\r");
00285 }
00286 if (!artist && col % 2 != 0)
00287 add_buf (buffer, "\n\r");
00288
00289 page_to_char (buf_string (buffer), ch);
00290 free_buf (buffer);
00291 return;
00292 }
00293
00294 if (!str_cmp (arg, "loud"))
00295 {
00296 argument = str;
00297 global = TRUE;
00298 }
00299
00300 if (argument[0] == '\0')
00301 {
00302 send_to_char ("Play what?\n\r", ch);
00303 return;
00304 }
00305
00306 if ((global &&channel_songs[MAX_GLOBAL] > -1)
00307 ||(!global &&juke->value[4] > -1))
00308 {
00309 send_to_char ("The jukebox is full up right now.\n\r", ch);
00310 return;
00311 }
00312
00313 for (song = 0; song < MAX_SONGS; song++)
00314 {
00315 if (song_table[song].name == NULL)
00316 {
00317 send_to_char ("That song isn't available.\n\r", ch);
00318 return;
00319 }
00320 if (!str_prefix (argument, song_table[song].name))
00321 break;
00322 }
00323
00324 if (song >= MAX_SONGS)
00325 {
00326 send_to_char ("That song isn't available.\n\r", ch);
00327 return;
00328 }
00329
00330 send_to_char ("Coming right up.\n\r", ch);
00331
00332 if (global)
00333 {
00334 for (i = 1; i <= MAX_GLOBAL; i++)
00335 if (channel_songs[i] < 0)
00336 {
00337 if (i == 1)
00338 channel_songs[0] = -1;
00339 channel_songs[i] = song;
00340 return;
00341 }
00342 }
00343 else
00344 {
00345 for (i = 1; i < 5; i++)
00346 if (juke->value[i] < 0)
00347 {
00348 if (i == 1)
00349 juke->value[0] = -1;
00350 juke->value[i] = song;
00351 return;
00352 }
00353 }
00354 }
|
Here is the call graph for this function:

|
|
Definition at line 160 of file music.c. References bug(), channel_songs, fread_letter(), fread_string(), fread_string_eol(), song_data::group, song_data::lines, song_data::lyrics, MAX_GLOBAL, MAX_LINES, MAX_SONGS, MUSIC_FILE, song_data::name, and song_table. Referenced by boot_db(). 00161 {
00162 FILE *fp;
00163 int count = 0, lines, i;
00164 char letter;
00165
00166 /* reset global */
00167 for (i = 0; i <= MAX_GLOBAL; i++)
00168 channel_songs[i] = -1;
00169
00170 if ((fp = fopen (MUSIC_FILE, "r")) == NULL)
00171 {
00172 bug ("Couldn't open music file, no songs available.", 0);
00173 fclose (fp);
00174 return;
00175 }
00176
00177 for (count = 0; count < MAX_SONGS; count++)
00178 {
00179 letter = fread_letter (fp);
00180 if (letter == '#')
00181 {
00182 if (count < MAX_SONGS)
00183 song_table[count].name = NULL;
00184 fclose (fp);
00185 return;
00186 }
00187 else
00188 ungetc (letter, fp);
00189
00190 song_table[count].group = fread_string (fp);
00191 song_table[count].name = fread_string (fp);
00192
00193 /* read lyrics */
00194 lines = 0;
00195
00196 for (;;)
00197 {
00198 letter = fread_letter (fp);
00199
00200 if (letter == '~')
00201 {
00202 song_table[count].lines = lines;
00203 break;
00204 }
00205 else
00206 ungetc (letter, fp);
00207
00208 if (lines >= MAX_LINES)
00209 {
00210 bug ("Too many lines in a song -- limit is %d.", MAX_LINES);
00211 break;
00212 }
00213
00214 song_table[count].lyrics[lines] = fread_string_eol (fp);
00215 lines++;
00216 }
00217 }
00218 }
|
Here is the call graph for this function:

|
|
Definition at line 45 of file music.c. References act, act_new(), obj_data::carried_by, channel_songs, descriptor_data::character, char_data::comm, COMM_NOMUSIC, COMM_QUIET, CON_PLAYING, descriptor_data::connected, descriptor_list, char_data::in_room, obj_data::in_room, IS_SET, ITEM_JUKEBOX, obj_data::item_type, song_data::lyrics, MAX_GLOBAL, MAX_LINES, MAX_SONGS, MAX_STRING_LENGTH, obj_data::name, obj_data::next, descriptor_data::next, object_list, descriptor_data::original, room_index_data::people, POS_SLEEPING, song_table, TO_ALL, TO_CHAR, and obj_data::value. Referenced by update_handler(). 00046 {
00047 OBJ_DATA *obj;
00048 CHAR_DATA *victim;
00049 ROOM_INDEX_DATA *room;
00050 DESCRIPTOR_DATA *d;
00051 char buf[MAX_STRING_LENGTH];
00052 char *line;
00053 int i;
00054
00055 /* do the global song, if any */
00056 if (channel_songs[1] >= MAX_SONGS)
00057 channel_songs[1] = -1;
00058
00059 if (channel_songs[1] > -1)
00060 {
00061 if (channel_songs[0] >= MAX_LINES
00062 || channel_songs[0] >= song_table[channel_songs[1]].lines)
00063 {
00064 channel_songs[0] = -1;
00065
00066 /* advance songs */
00067 for (i = 1; i < MAX_GLOBAL; i++)
00068 channel_songs[i] = channel_songs[i + 1];
00069 channel_songs[MAX_GLOBAL] = -1;
00070 }
00071 else
00072 {
00073 if (channel_songs[0] < 0)
00074 {
00075 sprintf (buf, "Music: %s, %s",
00076 song_table[channel_songs[1]].group,
00077 song_table[channel_songs[1]].name);
00078 channel_songs[0] = 0;
00079 }
00080 else
00081 {
00082 sprintf (buf, "Music: '%s'",
00083 song_table[channel_songs[1]].lyrics[channel_songs
00084 [0]]);
00085 channel_songs[0]++;
00086 }
00087
00088 for (d = descriptor_list; d != NULL; d = d->next)
00089 {
00090 victim = d->original ? d->original : d->character;
00091
00092 if (d->connected == CON_PLAYING &&
00093 !IS_SET (victim->comm, COMM_NOMUSIC) &&
00094 !IS_SET (victim->comm, COMM_QUIET))
00095 act_new ("$t", d->character, buf, NULL, TO_CHAR,
00096 POS_SLEEPING);
00097 }
00098 }
00099 }
00100
00101 for (obj = object_list; obj != NULL; obj = obj->next)
00102 {
00103 if (obj->item_type != ITEM_JUKEBOX || obj->value[1] < 0)
00104 continue;
00105
00106 if (obj->value[1] >= MAX_SONGS)
00107 {
00108 obj->value[1] = -1;
00109 continue;
00110 }
00111
00112 /* find which room to play in */
00113
00114 if ((room = obj->in_room) == NULL)
00115 {
00116 if (obj->carried_by == NULL)
00117 continue;
00118 else if ((room = obj->carried_by->in_room) == NULL)
00119 continue;
00120 }
00121
00122 if (obj->value[0] < 0)
00123 {
00124 sprintf (buf, "$p starts playing %s, %s.",
00125 song_table[obj->value[1]].group,
00126 song_table[obj->value[1]].name);
00127 if (room->people != NULL)
00128 act (buf, room->people, obj, NULL, TO_ALL);
00129 obj->value[0] = 0;
00130 continue;
00131 }
00132 else
00133 {
00134 if (obj->value[0] >= MAX_LINES
00135 || obj->value[0] >= song_table[obj->value[1]].lines)
00136 {
00137
00138 obj->value[0] = -1;
00139
00140 /* scroll songs forward */
00141 obj->value[1] = obj->value[2];
00142 obj->value[2] = obj->value[3];
00143 obj->value[3] = obj->value[4];
00144 obj->value[4] = -1;
00145 continue;
00146 }
00147
00148 line = song_table[obj->value[1]].lyrics[obj->value[0]];
00149 obj->value[0]++;
00150 }
00151
00152 sprintf (buf, "$p bops: '%s'", line);
00153 if (room->people != NULL)
00154 act (buf, room->people, obj, NULL, TO_ALL);
00155 }
00156 }
|
Here is the call graph for this function:

|
|
Definition at line 42 of file music.c. Referenced by do_play(), load_songs(), and song_update(). |
|
|
Definition at line 43 of file music.c. Referenced by do_play(), load_songs(), and song_update(). |
1.4.0