00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 }