Now that my character is dead, I can get back to coding
I'm not sure if anyone is the designated 'maintainer' of the messaging sub-systems, so I thought I should run this be the dev team to make sure I'm not treading on any toes...
I've been looking at the interaction between the 'sound' and 'message' code and I think I can see a way to clean up the code somewhat - in particular the use of #include "list-message.h" into a static array no less than three times in message.c
I think there is some scope to make 'sound' a much cleaner hook into the 'message' sub-system
Let's look first at the message queue:
We have linked list of message texts and linked list of message colours...
I propose:
1. Moving the colours out of here and create a new array (of size MSG_MAX) of structures that contain the colour and sound definitions
2. Reformat sound.cfg to be like messages.prf - something like:
3. Ditch the second column in list-message.h (it's only used to map the names used in sound.cfg anyway)
4. Get rid of message_lookup_by_sound_name() and message_sound_name() (no longer needed as they are used to map the current sound.cfg names to MSG_ numbers)
5. Replace calls to sound() with calls to msgt(), so
becomes
6. Convert many (if not all) calls to msg() to msgt() - Take, for example:
If we want to assign a sound to this one day, we'll need to either convert it then, or add the horribly hacky call to sound(). Why not just have
Now to the discussions about mp3, ogg, wav, etc...
Notice that I removed the file extension from sound.cfg (I think we can safely assume a rename to sound.cfg is in order btw). We can leave it up to each individual platform to support whatever format they can (possibly even multiple formats if we like).
This brings me to the final part of the cleanup (and I've mentioned this in a previous post) - moving the processing of sound.prf into a single location with hooks that each platform sets for the initialisation, loading, playing, and unloading of sounds
EDIT: We could just move the sound file names into message.prf
I'm not sure if anyone is the designated 'maintainer' of the messaging sub-systems, so I thought I should run this be the dev team to make sure I'm not treading on any toes...
I've been looking at the interaction between the 'sound' and 'message' code and I think I can see a way to clean up the code somewhat - in particular the use of #include "list-message.h" into a static array no less than three times in message.c
I think there is some scope to make 'sound' a much cleaner hook into the 'message' sub-system
Let's look first at the message queue:
Code:
typedef struct _msgqueue_t { message_t *head; message_t *tail; msgcolor_t *colors; u32b count; u32b max; } msgqueue_t;
I propose:
1. Moving the colours out of here and create a new array (of size MSG_MAX) of structures that contain the colour and sound definitions
2. Reformat sound.cfg to be like messages.prf - something like:
Code:
sound:DISSARM:plm_bang_ceramic plm_chest_latch plm_click_switch3
4. Get rid of message_lookup_by_sound_name() and message_sound_name() (no longer needed as they are used to map the current sound.cfg names to MSG_ numbers)
5. Replace calls to sound() with calls to msgt(), so
Code:
sound(MSG_MULTIPLY);
Code:
msgt(MSG_MULTIPLY, "");
Code:
msg("You feel stronger!");
Code:
msgt(MSG_STAT_GAIN, "You feel stronger!");
Notice that I removed the file extension from sound.cfg (I think we can safely assume a rename to sound.cfg is in order btw). We can leave it up to each individual platform to support whatever format they can (possibly even multiple formats if we like).
This brings me to the final part of the cleanup (and I've mentioned this in a previous post) - moving the processing of sound.prf into a single location with hooks that each platform sets for the initialisation, loading, playing, and unloading of sounds
EDIT: We could just move the sound file names into message.prf
Code:
message:<message-type>:<color>:<sound file> <sound file> ... <sound file>
Comment