| 89 | } |
| 90 | |
| 91 | static GameValue EvalFormat(const GameState*, GameValuePar arg) |
| 92 | { |
| 93 | const GameArrayType& array = arg; |
| 94 | if (array.Size() < 1 || array[0].GetType() != GameString) |
| 95 | return GameValue(""); |
| 96 | |
| 97 | RString format = array[0]; |
| 98 | int nParams = array.Size() - 1; |
| 99 | char result[2048]; |
| 100 | const char* src = format; |
| 101 | char* dst = result; |
| 102 | |
| 103 | while (char c = *src) |
| 104 | { |
| 105 | if (c == '%') |
| 106 | { |
| 107 | src++; |
| 108 | int index = 0; |
| 109 | while (isdigit((unsigned char)*src)) |
| 110 | { |
| 111 | index = index * 10 + (*src - '0'); |
| 112 | src++; |
| 113 | } |
| 114 | if (index < 1 || index > nParams) |
| 115 | continue; |
| 116 | const GameValue& value = array[index]; |
| 117 | RString text = (value.GetType() == GameString) ? value.GetData()->GetString() : value.GetText(); |
| 118 | strcpy(dst, text); |
| 119 | dst += text.GetLength(); |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | *dst++ = c; |
| 124 | src++; |
| 125 | } |
| 126 | } |
| 127 | *dst = 0; |
| 128 | return GameValue(result); |
| 129 | } |
| 130 | |
| 131 | static GameValue NularTime(const GameState*) |
| 132 | { |