static joy_char_t * LoadJoystickAlpha (STRING String, int *count) { UNICODE *str; int c; int i; joy_char_t *chars; UNICODE *cur; *count = 0; str = GetStringAddress (String); if (!str) return 0; c = utf8StringCount (str); chars = HMalloc (c * sizeof (*chars)); if (!chars) return 0; for (i = 0, cur = str; i < c; ++i) { int len = ReadOneChar (chars + i, cur); cur += len; } *count = c; return chars; }
void GetAllianceName (UNICODE *buf, RESPONSE_REF name_1) { COUNT i; STRING S; i = GET_GAME_STATE (NEW_ALLIANCE_NAME); S = SetAbsStringTableIndex (CommData.ConversationPhrases, (name_1 - 1) + i); // XXX: this should someday be changed so that the function takes // the buffer size as an argument strcpy (buf, (UNICODE *)GetStringAddress (S)); if (i == 3) { strcat (buf, GLOBAL_SIS (CommanderName)); strcat (buf, (UNICODE *)GetStringAddress (SetRelStringTableIndex (S, 1))); } }
void construct_response (UNICODE *buf, int R /* promoted from RESPONSE_REF */, ...) { UNICODE *buf_start = buf; UNICODE *name; va_list vlist; va_start (vlist, R); do { COUNT len; STRING S; S = SetAbsStringTableIndex (CommData.ConversationPhrases, R - 1); strcpy (buf, (UNICODE *)GetStringAddress (S)); len = strlen (buf); buf += len; name = va_arg (vlist, UNICODE *); if (name) { len = strlen (name); strncpy (buf, name, len); buf += len; /* if ((R = va_arg (vlist, RESPONSE_REF)) == (RESPONSE_REF)-1) name = 0; */ R = va_arg(vlist, int); if (R == ((RESPONSE_REF) -1)) name = 0; } } while (name); va_end (vlist); *buf = '\0'; // XXX: this should someday be changed so that the function takes // the buffer size as an argument if ((buf_start == shared_phrase_buf) && (buf > shared_phrase_buf + sizeof (shared_phrase_buf))) { log_add (log_Fatal, "Error: shared_phrase_buf size exceeded," " please increase!\n"); exit (EXIT_FAILURE); } }
// The type conversions are implicit and will generate errors // or warnings if types change imcompatibly COLORMAPPTR GetColorMapAddress (COLORMAP colormap) { return GetStringAddress (colormap); }
/** * Gets the content for index and loads it into the current conversation, * using the voice track cb if provided, or making one itself if not. * * The indices are: * - 1 000 000 : captain's name * - 999 999 : ship's name * - 999 998 : ship's location * numbers from -999 997 to 998 997 : display the name of your alliance * (not sure why this one option needs 1001 indices) * numbers from -998 996 to -1 : alien number speech (sign is flipped) * 0 : say and do nothing * positive numbers : entries from the current alien conversation's string table */ void NPCPhrase_cb (int index, TFB_TrackCB cb) { UNICODE *pStr, numbuf[400]; void *pClip, *pTimeStamp; switch (index) { case GLOBAL_PLAYER_NAME: pStr = GLOBAL_SIS (CommanderName); pClip = 0; pTimeStamp = 0; break; case GLOBAL_SHIP_NAME: pStr = GLOBAL_SIS (ShipName); pClip = 0; pTimeStamp = 0; break; case GLOBAL_PLAYER_LOCATION: { SIZE dx, dy; COUNT adx, ady; dx = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)) - 333; adx = dx >= 0 ? dx : -dx; dy = 9812 - LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); ady = dy >= 0 ? dy : -dy; sprintf (numbuf, "%+04d.%01u,%+04d.%01u", (SIZE)(dy / 10), (COUNT)(ady % 10), (SIZE)(dx / 10), (COUNT)(adx % 10)); pStr = numbuf; pClip = 0; pTimeStamp = 0; break; } case 0: { return; } default: if (index < 0) { if (index > UNREASONABLE_NUMBER) { if (CommData.AlienNumberSpeech) { NPCNumberPhrase (-index, NULL); return; } sprintf (numbuf, "%d", -index); } else { COUNT i; STRING S; index -= GLOBAL_ALLIANCE_NAME; i = GET_GAME_STATE (NEW_ALLIANCE_NAME); S = SetAbsStringTableIndex (CommData.ConversationPhrases, (index - 1) + i); strcpy (numbuf, (UNICODE *)GetStringAddress (S)); if (i == 3) strcat (numbuf, GLOBAL_SIS (CommanderName)); } pStr = numbuf; pClip = 0; pTimeStamp = 0; } else { pStr = (UNICODE *)GetStringAddress ( SetAbsStringTableIndex (CommData.ConversationPhrases, index - 1) ); pClip = GetStringSoundClip ( SetAbsStringTableIndex (CommData.ConversationPhrases, index - 1) ); pTimeStamp = GetStringTimeStamp ( SetAbsStringTableIndex (CommData.ConversationPhrases, index - 1) ); } break; } if (GLOBAL (glob_flags) & VOICE_DISABLED || pClip == NULL) pClip = "noname.ogg"; SpliceTrack (pClip, pStr, pTimeStamp, cb); }