Usecode.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-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 "Usecode.h"
00022 #include "CoreApp.h"
00023 
00024 uint32 Usecode::get_class_event(uint32 classid, uint32 eventid)
00025 {
00026         if (get_class_size(classid) == 0) return 0;
00027 
00028         if (eventid >= get_class_event_count(classid)) {
00029                 perr << "eventid too high: " << eventid << " >= " << get_class_event_count(classid) << " for class " << classid << std::endl;
00030                 CANT_HAPPEN();
00031         }
00032 
00033         const uint8* data = get_class(classid);
00034 
00035         uint32 offset;
00036         if (GAME_IS_U8) {
00037                 offset = data[12 + (eventid*4) + 0];
00038                 offset += data[12 + (eventid*4) + 1] << 8;
00039                 offset += data[12 + (eventid*4) + 2] << 16;
00040                 offset += data[12 + (eventid*4) + 3] << 24;
00041         } else if (GAME_IS_REMORSE) {
00042                 offset = data[20 + (eventid*6) + 2];
00043                 offset += data[20 + (eventid*6) + 3] << 8;
00044                 offset += data[20 + (eventid*6) + 4] << 16;
00045                 offset += data[20 + (eventid*6) + 5] << 24;
00046         } else {
00047                 CANT_HAPPEN_MSG("Invalid game type.");
00048         }
00049 
00050         return offset;
00051 }

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