00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029
00030 #include <fstream>
00031 #include <vector>
00032 #include "items.h"
00033 #include "utils.h"
00034 #include "msgfile.h"
00035
00036 using std::ifstream;
00037 using std::cerr;
00038 using std::endl;
00039 using std::vector;
00040
00041 char **item_names;
00042 int num_item_names;
00043
00044
00045
00046
00047
00048
00049
00050
00051 void Setup_item_names (ifstream& items, ifstream& msgs) {
00052 vector<char *> msglist;
00053 int first_msg;
00054
00055
00056 items.seekg(0x54);
00057 int flxcnt = Read4(items);
00058 first_msg = num_item_names = flxcnt;
00059 if (msgs.good()) {
00060 first_msg = Read_text_msg_file(msgs, msglist);
00061 if (first_msg >= 0) {
00062 if (first_msg < num_item_names) {
00063 cerr << "Exult msg. # " << first_msg <<
00064 " conflicts with 'text.flx'" << endl;
00065 first_msg = num_item_names;
00066 }
00067 num_item_names = msglist.size();
00068 } else
00069 first_msg = num_item_names;
00070 }
00071 item_names = new char *[num_item_names];
00072 int i;
00073 for(i=0; i < flxcnt; i++) {
00074 items.seekg(0x80+i*8);
00075 int itemoffs = Read4(items);
00076 if(!itemoffs)
00077 continue;
00078 int itemlen = Read4(items);
00079 items.seekg(itemoffs);
00080 item_names[i] = new char[itemlen];
00081 items.read(item_names[i], itemlen);
00082 #if 0
00083 cout << dec << i << " 0x" << hex << i << dec
00084 << "\t" << item_names[i] << endl;
00085 #endif
00086 }
00087 for (i = first_msg; i < num_item_names; i++)
00088 item_names[i] = msglist[i];
00089 }