start to add some SOUND_TRIGGER_ACHIEVEMENTS code
Start to add supporting code to windsound and macsound. The latter remains commented out because I haven't had a chance to try it on macOS yet. In order to test it out, I added two more stock sounds: sa2_xplevelup and sa2_xpleveldown.
This commit is contained in:
@@ -33,7 +33,8 @@ static void maybe_preinsert_directory(int32_t, char *, char *, size_t);
|
||||
struct sound_procs windsound_procs = {
|
||||
SOUNDID(windsound),
|
||||
SOUND_TRIGGER_USERSOUNDS | SOUND_TRIGGER_SOUNDEFFECTS
|
||||
| SOUND_TRIGGER_HEROMUSIC | SOUND_TRIGGER_AMBIENCE,
|
||||
| SOUND_TRIGGER_HEROMUSIC | SOUND_TRIGGER_AMBIENCE
|
||||
| SOUND_TRIGGER_ACHIEVEMENTS,
|
||||
windsound_init_nhsound,
|
||||
windsound_exit_nhsound,
|
||||
windsound_achievement,
|
||||
@@ -57,6 +58,54 @@ windsound_exit_nhsound(const char *reason)
|
||||
static void
|
||||
windsound_achievement(schar ach1, schar ach2, int32_t repeat)
|
||||
{
|
||||
int reslt = 0;
|
||||
const char *filename;
|
||||
char resourcename[120], buf[PATHLEN];
|
||||
int findsound_approach = sff_base_only;
|
||||
DWORD fdwsound = SND_NODEFAULT;
|
||||
char *exedir = (char *) 0;
|
||||
|
||||
adjust_soundargs_for_compiler(&findsound_approach, &fdwsound, &exedir);
|
||||
maybe_preinsert_directory(findsound_approach, exedir, buf, sizeof buf);
|
||||
fdwsound |= SND_ASYNC;
|
||||
|
||||
if (ach1 == 0 && ach2 == 0)
|
||||
return;
|
||||
|
||||
resourcename[0] = '\0';
|
||||
if (ach1 == 0) {
|
||||
int sa2 = (int) ach2;
|
||||
|
||||
if (sa2 > sa2_zero_invalid && sa2 < number_of_sa2_entries) {
|
||||
switch(sa2) {
|
||||
case sa2_splashscreen:
|
||||
Strcpy(resourcename, "sa2_splashscreen");
|
||||
break;
|
||||
case sa2_newgame_nosplash:
|
||||
Strcpy(resourcename, "sa2_newgame_nosplash");
|
||||
break;
|
||||
case sa2_restoregame:
|
||||
Strcpy(resourcename, "sa2_restoregame");
|
||||
break;
|
||||
case sa2_xplevelup:
|
||||
Strcpy(resourcename, "sa2_xplevelup");
|
||||
break;
|
||||
case sa2_xpleveldown:
|
||||
Strcpy(resourcename, "sa2_xpleveldown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resourcename[0] == '\0')
|
||||
return;
|
||||
adjust_soundargs_for_compiler(&findsound_approach, &fdwsound, &exedir);
|
||||
/* the final, or only, one is played ASYNC */
|
||||
maybe_preinsert_directory(findsound_approach, exedir, buf, sizeof buf);
|
||||
filename = base_soundname_to_filename(resourcename,
|
||||
buf, sizeof buf, findsound_approach);
|
||||
if (filename) {
|
||||
reslt = PlaySound(filename, NULL, fdwsound);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -239,7 +288,7 @@ adjust_soundargs_for_compiler(
|
||||
static void
|
||||
maybe_preinsert_directory(int32_t findsound_approach, char *exedir, char *buf, size_t sz)
|
||||
{
|
||||
int largest_se_basename = 35;
|
||||
int largest_basename = 35;
|
||||
|
||||
/* findsound_approach = sff_havdir_append_rest means a directory name will be
|
||||
* inserted into the begining of buf and the remaining parts of the
|
||||
@@ -250,7 +299,7 @@ maybe_preinsert_directory(int32_t findsound_approach, char *exedir, char *buf, s
|
||||
|
||||
if (findsound_approach == sff_havedir_append_rest) {
|
||||
if (exedir) {
|
||||
if (strlen(exedir) < (sz - largest_se_basename))
|
||||
if (strlen(exedir) < (sz - largest_basename))
|
||||
Strcpy(buf, exedir);
|
||||
else
|
||||
*buf = '\0';
|
||||
|
||||
Reference in New Issue
Block a user