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

Method LoadTable

editor/TableManage.cpp:151–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151bool GenericPageList::LoadTable(char *table_filename) {
152 CFILE *infile;
153 uint8_t pagetype;
154 int done;
155 uint32_t page_id;
156
157 GenericPageNode *generic_page_node;
158
159 infile = cfopen(table_filename, "rb");
160
161 if (!infile) {
162 // mprintf(0,"Couldn't open table file to reorder!\n");
163 // Int3();
164 return FALSE;
165 }
166
167 CWaitCursor wc;
168
169 // Wipeout the list first
170 ClearList();
171
172 done = 0;
173 page_id = 0;
174
175 while (!done) {
176 if (cfeof(infile)) {
177 done = 1;
178 continue;
179 }
180 pagetype = cf_ReadByte(infile);
181
182 // If not a generic page, just read it in and ignore it
183 if (pagetype != PAGETYPE_GENERIC) {
184 mng_ReadDummyPage(infile, pagetype);
185 page_id++;
186 continue;
187 }
188
189 generic_page_node = new GenericPageNode;
190 if (generic_page_node == NULL) {
191 return FALSE;
192 }
193 mng_ReadNewGenericPage(infile, &(generic_page_node->genericpage));
194 generic_page_node->page_id = page_id;
195 AddToList(generic_page_node);
196
197 page_id++;
198 }
199
200 cfclose(infile);
201
202 // Set Loaded tabel data
203 m_TableFilename = table_filename;
204 m_TableLoaded = TRUE;
205
206 m_TableModified = FALSE;
207
208 return TRUE;

Callers 1

OnTableEditFileLoadMethod · 0.80

Calls 6

cfopenFunction · 0.85
cfeofFunction · 0.85
cf_ReadByteFunction · 0.85
mng_ReadDummyPageFunction · 0.85
mng_ReadNewGenericPageFunction · 0.85
cfcloseFunction · 0.85

Tested by

no test coverage detected