Added melnorme number-speech (they will pronouce numbers now)

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@650 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2003-02-03 15:54:19 +00:00
parent c7fcdf0d5c
commit b4d1bb7cde
30 changed files with 364 additions and 5 deletions
+1
View File
@@ -205,6 +205,7 @@ static LOCDATA arilou_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -108,6 +108,7 @@ static LOCDATA blackurq_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -93,6 +93,7 @@ static LOCDATA chmmr_desc =
1, 0, /* FrameRate */ 1, 0, /* FrameRate */
1, 0, /* RestartRate */ 1, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -73,6 +73,7 @@ static LOCDATA commander_desc =
12, 8, /* FrameRate */ 12, 8, /* FrameRate */
14, 10, /* RestartRate */ 14, 10, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -129,6 +129,7 @@ static LOCDATA druuge_desc =
8, 8, /* FrameRate */ 8, 8, /* FrameRate */
10, 10, /* RestartRate */ 10, 10, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static COUNT SlaveryCount = 0; static COUNT SlaveryCount = 0;
+1
View File
@@ -79,6 +79,7 @@ static LOCDATA ilwrath_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+97 -1
View File
@@ -33,6 +33,8 @@ void DrawCargoStrings (BYTE OldElement, BYTE NewElement);
#define NUM_ALIEN_RACE_ITEMS 16 #define NUM_ALIEN_RACE_ITEMS 16
#define NUM_TECH_ITEMS 13 #define NUM_TECH_ITEMS 13
static NUMBER_SPEECH_DESC melnorme_numbers_english;
static LOCDATA melnorme_desc = static LOCDATA melnorme_desc =
{ {
NULL_PTR, /* init_encounter_func */ NULL_PTR, /* init_encounter_func */
@@ -92,8 +94,94 @@ static LOCDATA melnorme_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
&melnorme_numbers_english, /* AlienNumberSpeech - default */
}; };
static COUNT melnorme_digit_names[] =
{
ENUMERATE_ZERO,
ENUMERATE_ONE,
ENUMERATE_TWO,
ENUMERATE_THREE,
ENUMERATE_FOUR,
ENUMERATE_FIVE,
ENUMERATE_SIX,
ENUMERATE_SEVEN,
ENUMERATE_EIGHT,
ENUMERATE_NINE
};
static COUNT melnorme_teen_names[] =
{
ENUMERATE_TEN,
ENUMERATE_ELEVEN,
ENUMERATE_TWELVE,
ENUMERATE_THIRTEEN,
ENUMERATE_FOURTEEN,
ENUMERATE_FIFTEEN,
ENUMERATE_SIXTEEN,
ENUMERATE_SEVENTEEN,
ENUMERATE_EIGHTEEN,
ENUMERATE_NINETEEN
};
static COUNT melnorme_tens_names[] =
{
0, /* invalid */
0, /* skip digit */
ENUMERATE_TWENTY,
ENUMERATE_THIRTY,
ENUMERATE_FOURTY,
ENUMERATE_FIFTY,
ENUMERATE_SIXTY,
ENUMERATE_SEVENTY,
ENUMERATE_EIGHTY,
ENUMERATE_NINETY
};
static NUMBER_SPEECH_DESC melnorme_numbers_english =
{
5, /* NumDigits */
{
{ /* 1000-999999 */
1000, /* Divider */
0, /* Subtrahend */
NULL, /* StrDigits - recurse */
NULL, /* Names - not used */
ENUMERATE_THOUSAND /* CommonIndex */
},
{ /* 100-999 */
100, /* Divider */
0, /* Subtrahend */
melnorme_digit_names, /* StrDigits */
NULL, /* Names - not used */
ENUMERATE_HUNDRED /* CommonIndex */
},
{ /* 20-99 */
10, /* Divider */
0, /* Subtrahend */
melnorme_tens_names, /* StrDigits */
NULL, /* Names - not used */
0 /* CommonIndex - not used */
},
{ /* 10-19 */
1, /* Divider */
10, /* Subtrahend */
melnorme_teen_names, /* StrDigits */
NULL, /* Names - not used */
0 /* CommonIndex - not used */
},
{ /* 0-9 */
1, /* Divider */
0, /* Subtrahend */
melnorme_digit_names, /* StrDigits */
NULL, /* Names - not used */
0 /* CommonIndex - not used */
}
}
};
static void DoFirstMeeting (RESPONSE_REF R); static void DoFirstMeeting (RESPONSE_REF R);
static COUNT static COUNT
@@ -1047,6 +1135,7 @@ DoSell (RESPONSE_REF R)
BYTE num_new_rainbows; BYTE num_new_rainbows;
UWORD rainbow_mask; UWORD rainbow_mask;
SIZE added_credit; SIZE added_credit;
int what_to_sell_queued = 0;
rainbow_mask = MAKE_WORD ( rainbow_mask = MAKE_WORD (
GET_GAME_STATE (RAINBOW_WORLD0), GET_GAME_STATE (RAINBOW_WORLD0),
@@ -1074,7 +1163,13 @@ DoSell (RESPONSE_REF R)
NPCPhrase (SOLD_LIFE_DATA2); NPCPhrase (SOLD_LIFE_DATA2);
NPCPhrase (-(int)added_credit); NPCPhrase (-(int)added_credit);
NPCPhrase (SOLD_LIFE_DATA3); NPCPhrase (SOLD_LIFE_DATA3);
AlienTalkSegue ((COUNT)~0); // queue WHAT_TO_SELL before talk-segue
if (num_new_rainbows)
{
NPCPhrase (WHAT_TO_SELL);
what_to_sell_queued = 1;
}
AlienTalkSegue (1);
DrawCargoStrings ((BYTE)~0, (BYTE)~0); DrawCargoStrings ((BYTE)~0, (BYTE)~0);
SleepThread (ONE_SECOND / 2); SleepThread (ONE_SECOND / 2);
@@ -1129,6 +1224,7 @@ DoSell (RESPONSE_REF R)
if (GLOBAL_SIS (TotalBioMass) || num_new_rainbows) if (GLOBAL_SIS (TotalBioMass) || num_new_rainbows)
{ {
if (!what_to_sell_queued)
NPCPhrase (WHAT_TO_SELL); NPCPhrase (WHAT_TO_SELL);
if (GLOBAL_SIS (TotalBioMass)) if (GLOBAL_SIS (TotalBioMass))
+15 -1
View File
@@ -289,7 +289,21 @@ enum
ENUMERATE_FOURTEEN, ENUMERATE_FOURTEEN,
ENUMERATE_FIFTEEN, ENUMERATE_FIFTEEN,
ENUMERATE_SIXTEEN, ENUMERATE_SIXTEEN,
END_LIST_WITH_AND END_LIST_WITH_AND,
ENUMERATE_ZERO,
ENUMERATE_SEVENTEEN,
ENUMERATE_EIGHTEEN,
ENUMERATE_NINETEEN,
ENUMERATE_TWENTY,
ENUMERATE_THIRTY,
ENUMERATE_FOURTY,
ENUMERATE_FIFTY,
ENUMERATE_SIXTY,
ENUMERATE_SEVENTY,
ENUMERATE_EIGHTY,
ENUMERATE_NINETY,
ENUMERATE_HUNDRED,
ENUMERATE_THOUSAND
}; };
#endif /* _STRINGS_H */ #endif /* _STRINGS_H */
+1
View File
@@ -89,6 +89,7 @@ static LOCDATA mycon_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static BYTE MadeChoice = 0; static BYTE MadeChoice = 0;
+1
View File
@@ -148,6 +148,7 @@ static LOCDATA orz_desc =
8, 8, /* FrameRate */ 8, 8, /* FrameRate */
10, ONE_SECOND * 3 / 8, /* RestartRate */ 10, ONE_SECOND * 3 / 8, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -77,6 +77,7 @@ static LOCDATA pkunk_desc =
8, 20, /* FrameRate */ 8, 20, /* FrameRate */
10, ONE_SECOND / 2, /* RestartRate */ 10, ONE_SECOND / 2, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static BOOLEAN static BOOLEAN
+1
View File
@@ -170,6 +170,7 @@ static LOCDATA yehat_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -133,6 +133,7 @@ static LOCDATA shofixti_desc =
6, 0, /* FrameRate */ 6, 0, /* FrameRate */
8, 0, /* RestartRate */ 8, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static RESPONSE_REF shofixti_name; static RESPONSE_REF shofixti_name;
+15
View File
@@ -134,6 +134,21 @@ static LOCDATA slylandro_desc =
(1 << 10) | (1 << 11), /* BlockMask */ (1 << 10) | (1 << 11), /* BlockMask */
}, },
}, },
{ /* AlienTransitionDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
{ /* AlienTalkDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+15
View File
@@ -85,6 +85,21 @@ static LOCDATA slylandro_desc =
(1 << 2) /* BlockMask */ (1 << 2) /* BlockMask */
}, },
}, },
{ /* AlienTransitionDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
{ /* AlienTalkDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static RESPONSE_REF threat = 0, static RESPONSE_REF threat = 0,
+15
View File
@@ -149,6 +149,21 @@ static LOCDATA spahome_desc =
(1 << 12), /* BlockMask */ (1 << 12), /* BlockMask */
}, },
}, },
{ /* AlienTransitionDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
{ /* AlienTalkDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+11 -2
View File
@@ -101,7 +101,6 @@ static LOCDATA spathi_desc =
ONE_SECOND, ONE_SECOND * 3, /* RestartRate */ ONE_SECOND, ONE_SECOND * 3, /* RestartRate */
}, },
}, },
#ifdef NEVER
{ {
0, /* StartIndex */ 0, /* StartIndex */
0, /* NumFrames */ 0, /* NumFrames */
@@ -109,14 +108,24 @@ static LOCDATA spathi_desc =
0, 0, /* FrameRate */ 0, 0, /* FrameRate */
0, 0, /* RestartRate */ 0, 0, /* RestartRate */
}, },
{ #ifdef NEVER
{ /* AlienTalkDesc */
29, /* StartIndex */ 29, /* StartIndex */
5, /* NumFrames */ 5, /* NumFrames */
0, /* AnimFlags */ 0, /* AnimFlags */
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
#else
{ /* AlienTalkDesc - empty */
0, /* StartIndex */
0, /* NumFrames */
0, /* AnimFlags */
0, 0, /* FrameRate */
0, 0, /* RestartRate */
},
#endif /* NEVER */ #endif /* NEVER */
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -130,6 +130,7 @@ static LOCDATA commander_desc =
12, 8, /* FrameRate */ 12, 8, /* FrameRate */
14, 10, /* RestartRate */ 14, 10, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static DWORD CurBulletinMask; static DWORD CurBulletinMask;
+1
View File
@@ -80,6 +80,7 @@ static LOCDATA supox_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -164,6 +164,7 @@ static LOCDATA syreen_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -172,6 +172,7 @@ static LOCDATA talkpet_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
#define NUM_STROBES 10 #define NUM_STROBES 10
+1
View File
@@ -113,6 +113,7 @@ static LOCDATA thradd_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static int static int
+1
View File
@@ -175,6 +175,7 @@ static LOCDATA umgah_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -100,6 +100,7 @@ static LOCDATA urquan_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -166,6 +166,7 @@ static LOCDATA utwig_desc =
6, 6, /* FrameRate */ 6, 6, /* FrameRate */
14, ONE_SECOND / 2, /* RestartRate */ 14, ONE_SECOND / 2, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -172,6 +172,7 @@ static LOCDATA vux_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -170,6 +170,7 @@ static LOCDATA yehat_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
static void static void
+1
View File
@@ -89,6 +89,7 @@ static LOCDATA zoqfot_desc =
8, 0, /* FrameRate */ 8, 0, /* FrameRate */
10, 0, /* RestartRate */ 10, 0, /* RestartRate */
}, },
NULL_PTR, /* AlienNumberSpeech - none */
}; };
enum enum
+114
View File
@@ -20,6 +20,9 @@
#include "commglue.h" #include "commglue.h"
#include "libs/sound/trackplayer.h" #include "libs/sound/trackplayer.h"
#include <stdarg.h> #include <stdarg.h>
#include <assert.h>
int NPCNumberPhrase (int number, UNICODE **ptrack);
void void
NPCPhrase (int index) NPCPhrase (int index)
@@ -61,7 +64,14 @@ NPCPhrase (int index)
if (index < 0) if (index < 0)
{ {
if (index > UNREASONABLE_NUMBER) if (index > UNREASONABLE_NUMBER)
{
if (CommData.AlienNumberSpeech)
{
NPCNumberPhrase (-index, NULL);
return;
}
sprintf (numbuf, "%d", -index); sprintf (numbuf, "%d", -index);
}
else else
{ {
COUNT i; COUNT i;
@@ -97,6 +107,110 @@ NPCPhrase (int index)
SpliceTrack (pClip, pStr, pTimeStamp); SpliceTrack (pClip, pStr, pTimeStamp);
} }
int
NPCNumberPhrase (int number, UNICODE **ptrack)
{
#define MAX_NUMBER_TRACKS 20
NUMBER_SPEECH speech = CommData.AlienNumberSpeech;
COUNT i;
int queued = 0;
int toplevel = 0;
UNICODE *TrackNames[MAX_NUMBER_TRACKS];
UNICODE numbuf[32];
if (!speech)
return 0;
if (!ptrack)
{
toplevel = 1;
sprintf (numbuf, "%d", number);
ptrack = TrackNames;
}
for (i = 0; i < speech->NumDigits; ++i)
{
SPEECH_DIGIT* dig = speech->Digits + i;
int quot;
quot = number / dig->Divider;
if (quot == 0)
continue;
quot -= dig->Subtrahend;
if (quot < 0)
continue;
if (dig->StrDigits)
{
COUNT index;
assert (quot < 10);
index = dig->StrDigits[quot];
if (index == 0)
continue;
index -= 1;
*ptrack++ = GetStringSoundClip (SetAbsStringTableIndex (
CommData.ConversationPhrases, index
));
queued++;
}
else
{
int ctracks = NPCNumberPhrase (quot, ptrack);
ptrack += ctracks;
queued += ctracks;
}
if (dig->Names != 0)
{
SPEECH_DIGITNAME* name;
for (name = dig->Names; name->Divider; ++name)
{
if (number % name->Divider <= name->MaxRemainder)
{
*ptrack++ = GetStringSoundClip (
SetAbsStringTableIndex (
CommData.ConversationPhrases,
(COUNT) (name->StrIndex - 1)
));
queued++;
break;
}
}
}
else if (dig->CommonNameIndex != 0)
{
*ptrack++ = GetStringSoundClip (SetAbsStringTableIndex (
CommData.ConversationPhrases,
(COUNT) (dig->CommonNameIndex - 1)
));
queued++;
}
number %= dig->Divider;
}
if (toplevel)
{
if (queued == 0)
{ // nothing queued, say "zero"
*ptrack++ = GetStringSoundClip (SetAbsStringTableIndex (
CommData.ConversationPhrases,
speech->Digits[speech->NumDigits - 1].StrDigits[0]
));
}
*ptrack++ = NULL; // term
SpliceMultiTrack (TrackNames, numbuf);
}
return queued;
}
void void
GetAllianceName (UNICODE *buf, RESPONSE_REF name_1) GetAllianceName (UNICODE *buf, RESPONSE_REF name_1)
{ {
+59
View File
@@ -49,6 +49,64 @@ typedef ANIMATION_DESC *PANIMATION_DESC;
#define MAX_ANIMATIONS 20 #define MAX_ANIMATIONS 20
// general numbers-speech generator info
// should accomodate most common base-10 languages
// many languages require various plural forms
// for digit names like "hundred"
// possibly needs reworking for others
typedef struct
{
// an array of these structs must be in ascending remainder order
// terminate the array with Divider == 0
// digit divider, i.e. 1, 10, 100, etc.
int Divider;
// maximum remainder for this name
// name will be used if Number % Divider <= MaxRemainder
int MaxRemainder;
// string table index for this name
// i.e. "hundred" in English
COUNT StrIndex;
} SPEECH_DIGITNAME;
typedef struct
{
// digit divider, i.e. 1, 10, 100, etc.
int Divider;
// digit sub, i.e. 10 for teens
// subtracted from the value to get an index into StrDigits
int Subtrahend;
// ptr to 10 indices for this digit
// index is string table ptr when > 0
// is invalid (should not happen) or
// is a a 'skip digit' indicator when == 0
// StrDigits can be NULL, in which case
// the value is interpreted recursively
COUNT *StrDigits;
// digit Names, can be NULL, in which case
// CommonNameIndex is used
SPEECH_DIGITNAME *Names;
// common digit name string table index
// i.e. "hundred" in English
COUNT CommonNameIndex;
} SPEECH_DIGIT;
// this accomodates up to "billions" in english
#define MAX_SPEECH_DIGITS 7
typedef struct
{
// slots used in Digits array
COUNT NumDigits;
// slots for each digit in numbers
// teens is exception
// 0-9, 10-19, ..20-90, ..100-900, etc.
SPEECH_DIGIT Digits[MAX_SPEECH_DIGITS];
} NUMBER_SPEECH_DESC;
typedef NUMBER_SPEECH_DESC *PNUMBER_SPEECH_DESC;
#define NUMBER_SPEECH_DESCPTR PNUMBER_SPEECH_DESC
typedef NUMBER_SPEECH_DESC *NUMBER_SPEECH;
typedef struct typedef struct
{ {
void (*init_encounter_func) (void); void (*init_encounter_func) (void);
@@ -69,6 +127,7 @@ typedef struct
ANIMATION_DESC AlienTransitionDesc; ANIMATION_DESC AlienTransitionDesc;
ANIMATION_DESC AlienTalkDesc; ANIMATION_DESC AlienTalkDesc;
NUMBER_SPEECH AlienNumberSpeech;
TEXT AlienTextTemplate; TEXT AlienTextTemplate;
} LOCDATA; } LOCDATA;
typedef LOCDATA *PLOCDATA; typedef LOCDATA *PLOCDATA;