MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadStringTables

Function LoadStringTables

Descent3/localization.cpp:153–218  ·  view source on GitHub ↗

Call this to load up the string tables into memory Returns the number of strings loaded, if this is 0, then the program MUST not continue

Source from the content-addressed store, hash-verified

151// Call this to load up the string tables into memory
152// Returns the number of strings loaded, if this is 0, then the program MUST not continue
153int LoadStringTables(void) {
154 static bool called = false;
155 int old_language;
156
157 if (called) {
158 // Only call this guy once
159 Int3();
160 return 0;
161 }
162 called = true;
163
164 old_language = Localization_language;
165
166 int string_count = GetTotalStringCount();
167 if (string_count == 0) {
168 // attempt to load english version of language, so there is something
169 if (Localization_language != LANGUAGE_ENGLISH) {
170 Localization_language = LANGUAGE_ENGLISH;
171 string_count = GetTotalStringCount();
172 }
173
174 if (string_count == 0) {
175 return 0;
176 }
177 }
178
179 String_table_size = 0;
180
181 // malloc our array of char *
182 String_table = (char **)mem_malloc(sizeof(char *) * string_count);
183 if (!String_table) {
184 Localization_language = old_language;
185 return 0;
186 }
187
188 for (int tcount = 0; tcount < string_count; tcount++)
189 String_table[tcount] = NULL;
190
191 int runcount = 0;
192 int temp;
193 int index = 0;
194 while (String_table_list[index]) {
195 temp = LoadStringFile(String_table_list[index], runcount);
196 if (temp == 0) {
197 Localization_language = old_language;
198 return 0;
199 }
200 if (runcount + temp > string_count) {
201 Localization_language = old_language;
202 return 0;
203 }
204 runcount += temp;
205 index++;
206 }
207
208 if (runcount == 0) {
209 Localization_language = old_language;
210 return 0;

Callers 1

InitStringTableFunction · 0.85

Calls 2

GetTotalStringCountFunction · 0.85
LoadStringFileFunction · 0.85

Tested by

no test coverage detected