diff --git a/sc2/src/sc2code/comm/arilou/arilouc.c b/sc2/src/sc2code/comm/arilou/arilouc.c index 6d79f3d9c..1995f62d0 100644 --- a/sc2/src/sc2code/comm/arilou/arilouc.c +++ b/sc2/src/sc2code/comm/arilou/arilouc.c @@ -205,6 +205,7 @@ static LOCDATA arilou_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/blackur/blackurc.c b/sc2/src/sc2code/comm/blackur/blackurc.c index eb5485f09..f86d1f1cc 100644 --- a/sc2/src/sc2code/comm/blackur/blackurc.c +++ b/sc2/src/sc2code/comm/blackur/blackurc.c @@ -108,6 +108,7 @@ static LOCDATA blackurq_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/chmmr/chmmrc.c b/sc2/src/sc2code/comm/chmmr/chmmrc.c index f86f657ca..8c6e5ca97 100644 --- a/sc2/src/sc2code/comm/chmmr/chmmrc.c +++ b/sc2/src/sc2code/comm/chmmr/chmmrc.c @@ -93,6 +93,7 @@ static LOCDATA chmmr_desc = 1, 0, /* FrameRate */ 1, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/comandr/comandr.c b/sc2/src/sc2code/comm/comandr/comandr.c index a11820a0c..bf5b756b0 100644 --- a/sc2/src/sc2code/comm/comandr/comandr.c +++ b/sc2/src/sc2code/comm/comandr/comandr.c @@ -73,6 +73,7 @@ static LOCDATA commander_desc = 12, 8, /* FrameRate */ 14, 10, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/druuge/druugec.c b/sc2/src/sc2code/comm/druuge/druugec.c index 4f61c9fc6..796417ee6 100644 --- a/sc2/src/sc2code/comm/druuge/druugec.c +++ b/sc2/src/sc2code/comm/druuge/druugec.c @@ -129,6 +129,7 @@ static LOCDATA druuge_desc = 8, 8, /* FrameRate */ 10, 10, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static COUNT SlaveryCount = 0; diff --git a/sc2/src/sc2code/comm/ilwrath/ilwrathc.c b/sc2/src/sc2code/comm/ilwrath/ilwrathc.c index 5bdd83f5f..ae7ef3440 100644 --- a/sc2/src/sc2code/comm/ilwrath/ilwrathc.c +++ b/sc2/src/sc2code/comm/ilwrath/ilwrathc.c @@ -79,6 +79,7 @@ static LOCDATA ilwrath_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/melnorm/melnorm.c b/sc2/src/sc2code/comm/melnorm/melnorm.c index 30c7b3ded..2a8bcc871 100644 --- a/sc2/src/sc2code/comm/melnorm/melnorm.c +++ b/sc2/src/sc2code/comm/melnorm/melnorm.c @@ -33,6 +33,8 @@ void DrawCargoStrings (BYTE OldElement, BYTE NewElement); #define NUM_ALIEN_RACE_ITEMS 16 #define NUM_TECH_ITEMS 13 +static NUMBER_SPEECH_DESC melnorme_numbers_english; + static LOCDATA melnorme_desc = { NULL_PTR, /* init_encounter_func */ @@ -92,8 +94,94 @@ static LOCDATA melnorme_desc = 8, 0, /* FrameRate */ 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 COUNT @@ -1047,6 +1135,7 @@ DoSell (RESPONSE_REF R) BYTE num_new_rainbows; UWORD rainbow_mask; SIZE added_credit; + int what_to_sell_queued = 0; rainbow_mask = MAKE_WORD ( GET_GAME_STATE (RAINBOW_WORLD0), @@ -1074,7 +1163,13 @@ DoSell (RESPONSE_REF R) NPCPhrase (SOLD_LIFE_DATA2); NPCPhrase (-(int)added_credit); 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); SleepThread (ONE_SECOND / 2); @@ -1129,7 +1224,8 @@ DoSell (RESPONSE_REF R) if (GLOBAL_SIS (TotalBioMass) || num_new_rainbows) { - NPCPhrase (WHAT_TO_SELL); + if (!what_to_sell_queued) + NPCPhrase (WHAT_TO_SELL); if (GLOBAL_SIS (TotalBioMass)) Response (sell_life_data, DoSell); diff --git a/sc2/src/sc2code/comm/melnorm/strings.h b/sc2/src/sc2code/comm/melnorm/strings.h index f79f289ed..703ebc628 100644 --- a/sc2/src/sc2code/comm/melnorm/strings.h +++ b/sc2/src/sc2code/comm/melnorm/strings.h @@ -289,7 +289,21 @@ enum ENUMERATE_FOURTEEN, ENUMERATE_FIFTEEN, 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 */ diff --git a/sc2/src/sc2code/comm/mycon/myconc.c b/sc2/src/sc2code/comm/mycon/myconc.c index 5f026cbd1..9c75e1e5c 100644 --- a/sc2/src/sc2code/comm/mycon/myconc.c +++ b/sc2/src/sc2code/comm/mycon/myconc.c @@ -89,6 +89,7 @@ static LOCDATA mycon_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static BYTE MadeChoice = 0; diff --git a/sc2/src/sc2code/comm/orz/orzc.c b/sc2/src/sc2code/comm/orz/orzc.c index 42f88085b..5fa239c15 100644 --- a/sc2/src/sc2code/comm/orz/orzc.c +++ b/sc2/src/sc2code/comm/orz/orzc.c @@ -148,6 +148,7 @@ static LOCDATA orz_desc = 8, 8, /* FrameRate */ 10, ONE_SECOND * 3 / 8, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/pkunk/pkunkc.c b/sc2/src/sc2code/comm/pkunk/pkunkc.c index e14291388..b69540e8d 100644 --- a/sc2/src/sc2code/comm/pkunk/pkunkc.c +++ b/sc2/src/sc2code/comm/pkunk/pkunkc.c @@ -77,6 +77,7 @@ static LOCDATA pkunk_desc = 8, 20, /* FrameRate */ 10, ONE_SECOND / 2, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static BOOLEAN diff --git a/sc2/src/sc2code/comm/rebel/rebel.c b/sc2/src/sc2code/comm/rebel/rebel.c index 1f4d1113a..00a626067 100644 --- a/sc2/src/sc2code/comm/rebel/rebel.c +++ b/sc2/src/sc2code/comm/rebel/rebel.c @@ -170,6 +170,7 @@ static LOCDATA yehat_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/shofixt/shofixt.c b/sc2/src/sc2code/comm/shofixt/shofixt.c index 4e45c9020..d4720449b 100644 --- a/sc2/src/sc2code/comm/shofixt/shofixt.c +++ b/sc2/src/sc2code/comm/shofixt/shofixt.c @@ -133,6 +133,7 @@ static LOCDATA shofixti_desc = 6, 0, /* FrameRate */ 8, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static RESPONSE_REF shofixti_name; diff --git a/sc2/src/sc2code/comm/slyhome/slyhome.c b/sc2/src/sc2code/comm/slyhome/slyhome.c index 5e2267065..20d41bc8c 100644 --- a/sc2/src/sc2code/comm/slyhome/slyhome.c +++ b/sc2/src/sc2code/comm/slyhome/slyhome.c @@ -134,6 +134,21 @@ static LOCDATA slylandro_desc = (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 diff --git a/sc2/src/sc2code/comm/slyland/slyland.c b/sc2/src/sc2code/comm/slyland/slyland.c index 85c6e6998..b0dedfe65 100644 --- a/sc2/src/sc2code/comm/slyland/slyland.c +++ b/sc2/src/sc2code/comm/slyland/slyland.c @@ -85,6 +85,21 @@ static LOCDATA slylandro_desc = (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, diff --git a/sc2/src/sc2code/comm/spahome/spahome.c b/sc2/src/sc2code/comm/spahome/spahome.c index 83bb3958f..5a64469f3 100644 --- a/sc2/src/sc2code/comm/spahome/spahome.c +++ b/sc2/src/sc2code/comm/spahome/spahome.c @@ -149,6 +149,21 @@ static LOCDATA spahome_desc = (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 diff --git a/sc2/src/sc2code/comm/spathi/spathic.c b/sc2/src/sc2code/comm/spathi/spathic.c index 1fec45b9d..74c0bb939 100644 --- a/sc2/src/sc2code/comm/spathi/spathic.c +++ b/sc2/src/sc2code/comm/spathi/spathic.c @@ -101,7 +101,6 @@ static LOCDATA spathi_desc = ONE_SECOND, ONE_SECOND * 3, /* RestartRate */ }, }, -#ifdef NEVER { 0, /* StartIndex */ 0, /* NumFrames */ @@ -109,14 +108,24 @@ static LOCDATA spathi_desc = 0, 0, /* FrameRate */ 0, 0, /* RestartRate */ }, - { +#ifdef NEVER + { /* AlienTalkDesc */ 29, /* StartIndex */ 5, /* NumFrames */ 0, /* AnimFlags */ 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, +#else + { /* AlienTalkDesc - empty */ + 0, /* StartIndex */ + 0, /* NumFrames */ + 0, /* AnimFlags */ + 0, 0, /* FrameRate */ + 0, 0, /* RestartRate */ + }, #endif /* NEVER */ + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/starbas/starbas.c b/sc2/src/sc2code/comm/starbas/starbas.c index 62ed23e96..0f69a195d 100644 --- a/sc2/src/sc2code/comm/starbas/starbas.c +++ b/sc2/src/sc2code/comm/starbas/starbas.c @@ -130,6 +130,7 @@ static LOCDATA commander_desc = 12, 8, /* FrameRate */ 14, 10, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static DWORD CurBulletinMask; diff --git a/sc2/src/sc2code/comm/supox/supoxc.c b/sc2/src/sc2code/comm/supox/supoxc.c index f11b48c86..b75a61fde 100644 --- a/sc2/src/sc2code/comm/supox/supoxc.c +++ b/sc2/src/sc2code/comm/supox/supoxc.c @@ -80,6 +80,7 @@ static LOCDATA supox_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/syreen/syreenc.c b/sc2/src/sc2code/comm/syreen/syreenc.c index a2d90d5c1..6a5a0f799 100644 --- a/sc2/src/sc2code/comm/syreen/syreenc.c +++ b/sc2/src/sc2code/comm/syreen/syreenc.c @@ -164,6 +164,7 @@ static LOCDATA syreen_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/talkpet/talkpet.c b/sc2/src/sc2code/comm/talkpet/talkpet.c index 96b69f7e7..10ba8f1c3 100644 --- a/sc2/src/sc2code/comm/talkpet/talkpet.c +++ b/sc2/src/sc2code/comm/talkpet/talkpet.c @@ -172,6 +172,7 @@ static LOCDATA talkpet_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; #define NUM_STROBES 10 diff --git a/sc2/src/sc2code/comm/thradd/thraddc.c b/sc2/src/sc2code/comm/thradd/thraddc.c index 5f3b6f39f..a6b4eb3a8 100644 --- a/sc2/src/sc2code/comm/thradd/thraddc.c +++ b/sc2/src/sc2code/comm/thradd/thraddc.c @@ -113,6 +113,7 @@ static LOCDATA thradd_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static int diff --git a/sc2/src/sc2code/comm/umgah/umgahc.c b/sc2/src/sc2code/comm/umgah/umgahc.c index deb39b416..e2a016642 100644 --- a/sc2/src/sc2code/comm/umgah/umgahc.c +++ b/sc2/src/sc2code/comm/umgah/umgahc.c @@ -175,6 +175,7 @@ static LOCDATA umgah_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/urquan/urquanc.c b/sc2/src/sc2code/comm/urquan/urquanc.c index 06bcaf592..0333ecb5c 100644 --- a/sc2/src/sc2code/comm/urquan/urquanc.c +++ b/sc2/src/sc2code/comm/urquan/urquanc.c @@ -100,6 +100,7 @@ static LOCDATA urquan_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/utwig/utwigc.c b/sc2/src/sc2code/comm/utwig/utwigc.c index 29d2894e8..7d1b7c1f6 100644 --- a/sc2/src/sc2code/comm/utwig/utwigc.c +++ b/sc2/src/sc2code/comm/utwig/utwigc.c @@ -166,6 +166,7 @@ static LOCDATA utwig_desc = 6, 6, /* FrameRate */ 14, ONE_SECOND / 2, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/vux/vuxc.c b/sc2/src/sc2code/comm/vux/vuxc.c index e8b54974a..c18997553 100644 --- a/sc2/src/sc2code/comm/vux/vuxc.c +++ b/sc2/src/sc2code/comm/vux/vuxc.c @@ -172,6 +172,7 @@ static LOCDATA vux_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/yehat/yehatc.c b/sc2/src/sc2code/comm/yehat/yehatc.c index cad6a0f62..5041bcdd6 100644 --- a/sc2/src/sc2code/comm/yehat/yehatc.c +++ b/sc2/src/sc2code/comm/yehat/yehatc.c @@ -170,6 +170,7 @@ static LOCDATA yehat_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; static void diff --git a/sc2/src/sc2code/comm/zoqfot/zoqfotc.c b/sc2/src/sc2code/comm/zoqfot/zoqfotc.c index 167e04035..16a47693c 100644 --- a/sc2/src/sc2code/comm/zoqfot/zoqfotc.c +++ b/sc2/src/sc2code/comm/zoqfot/zoqfotc.c @@ -89,6 +89,7 @@ static LOCDATA zoqfot_desc = 8, 0, /* FrameRate */ 10, 0, /* RestartRate */ }, + NULL_PTR, /* AlienNumberSpeech - none */ }; enum diff --git a/sc2/src/sc2code/commglue.c b/sc2/src/sc2code/commglue.c index 9712cd476..3864e7aea 100644 --- a/sc2/src/sc2code/commglue.c +++ b/sc2/src/sc2code/commglue.c @@ -20,6 +20,9 @@ #include "commglue.h" #include "libs/sound/trackplayer.h" #include +#include + +int NPCNumberPhrase (int number, UNICODE **ptrack); void NPCPhrase (int index) @@ -61,7 +64,14 @@ NPCPhrase (int index) if (index < 0) { if (index > UNREASONABLE_NUMBER) + { + if (CommData.AlienNumberSpeech) + { + NPCNumberPhrase (-index, NULL); + return; + } sprintf (numbuf, "%d", -index); + } else { COUNT i; @@ -97,6 +107,110 @@ NPCPhrase (int index) 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 GetAllianceName (UNICODE *buf, RESPONSE_REF name_1) { diff --git a/sc2/src/sc2code/globdata.h b/sc2/src/sc2code/globdata.h index 136183127..2bbb1fd01 100644 --- a/sc2/src/sc2code/globdata.h +++ b/sc2/src/sc2code/globdata.h @@ -49,6 +49,64 @@ typedef ANIMATION_DESC *PANIMATION_DESC; #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 { void (*init_encounter_func) (void); @@ -69,6 +127,7 @@ typedef struct ANIMATION_DESC AlienTransitionDesc; ANIMATION_DESC AlienTalkDesc; + NUMBER_SPEECH AlienNumberSpeech; TEXT AlienTextTemplate; } LOCDATA; typedef LOCDATA *PLOCDATA;