UsecodeFlex.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2002-2006 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "UsecodeFlex.h"
00022 #include "CoreApp.h"
00023 #include "GameInfo.h"
00024 
00025 const uint8* UsecodeFlex::get_class(uint32 classid)
00026 {
00027         const uint8* obj = get_object_nodel(classid+2);
00028         return obj;
00029 }
00030 
00031 uint32 UsecodeFlex::get_class_size(uint32 classid)
00032 {
00033         uint32 size = get_size(classid+2);
00034         return size;
00035 }
00036 
00037 const char* UsecodeFlex::get_class_name(uint32 classid)
00038 {
00039         if (get_size(classid+2) > 0) {
00040                 const uint8* name_object = get_object_nodel(1);
00041                 return reinterpret_cast<const char*>(name_object+4+(13 * classid));
00042         } else {
00043                 return 0;
00044         }
00045 }
00046 
00047 uint32 UsecodeFlex::get_class_base_offset(uint32 classid)
00048 {
00049         if (get_size(classid+2) == 0) return 0;
00050 
00051         if (GAME_IS_U8) {
00052                 return 0x0C;
00053         } else if (GAME_IS_CRUSADER) {
00054                 const uint8* obj = get_object_nodel(classid+2);
00055                 uint32 offset = obj[8];
00056                 offset += obj[9] << 8;
00057                 offset += obj[10] << 16;
00058                 offset += obj[11] << 24;
00059                 offset--;
00060                 return offset;
00061         } else {
00062                 CANT_HAPPEN_MSG("Invalid game type.");
00063                 return 0;
00064         }
00065 }
00066 
00067 uint32 UsecodeFlex::get_class_event_count(uint32 classid)
00068 {
00069         if (get_size(classid+2) == 0) return 0;
00070 
00071         if (GAME_IS_U8) {
00072                 return 32;
00073         } else if (GAME_IS_CRUSADER) {
00074                 return (get_class_base_offset(classid)+19)/6;
00075         } else {
00076                 CANT_HAPPEN_MSG("Invalid game type.");
00077                 return 0;
00078         }
00079 }

Generated on Fri Jul 27 22:27:52 2007 for pentagram by  doxygen 1.4.7