items.cc

Go to the documentation of this file.
00001 
00007 /*
00008 Copyright (C) 1998  Jeffrey S. Freedman
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifdef HAVE_CONFIG_H
00026 #  include <config.h>
00027 #endif
00028 
00029 // #include <iomanip>     /* Debugging */
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;      // Names of U7 items.
00042 int num_item_names;
00043 
00044 
00045 /*
00046  *  Set up names of items.
00047  *
00048  *  Frame names start at entry 0x500 (reagents,medallions,food,etc.).
00049  */
00050 
00051 void Setup_item_names (ifstream& items, ifstream& msgs) {
00052   vector<char *> msglist;
00053   int first_msg;      // First in exultmsg.txt.  Should
00054           //   follow those in text.flx.
00055 
00056   items.seekg(0x54);
00057   int flxcnt = Read4(items);
00058   first_msg = num_item_names = flxcnt;
00059   if (msgs.good()) {    // Exult msgs. too?
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 } 

Generated on Mon Jul 9 14:42:50 2007 for ExultEngine by  doxygen 1.5.1