Reconstruct lab story, interactions, patrol and jet pack practice flow
This commit is contained in:
1 parent
58424120bb
commit
c929f942e1
84 files changed
+7957
-305
No files matched your search
@@ -0,0 +1,134 @@
|
||||
/* Original-DLL conversion probe. Run only against an isolated COPIED install.
|
||||
* API: collision_mode2_probe.exe [ASE\jimstop.ase] [object_mode=2] [animation_mode=2]
|
||||
* Reads source bytes, converts into in-memory OMT objects/database, prints bounded
|
||||
* geometry/frame-offset summaries. Never writes original asset files. */
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#define OMT_THISCALL __attribute__((thiscall))
|
||||
typedef void *(OMT_THISCALL *ctor0)(void *);
|
||||
typedef void *(OMT_THISCALL *dbctor)(void *, void *);
|
||||
typedef void (OMT_THISCALL *writefn)(void *, void *, unsigned);
|
||||
typedef void (OMT_THISCALL *seekfn)(void *, unsigned, short);
|
||||
typedef void *(OMT_THISCALL *converterctor)(void *, void *, void *);
|
||||
typedef void (OMT_THISCALL *convertfn)(void *);
|
||||
typedef void *(__cdecl *builderfn)(void);
|
||||
typedef void (__cdecl *registerfn)(unsigned, builderfn, long);
|
||||
typedef void *(OMT_THISCALL *getfn)(void *, unsigned, long);
|
||||
typedef float (OMT_THISCALL *magnitudefn)(const void *);
|
||||
static FARPROC required(HMODULE h, const char *name) {
|
||||
FARPROC p=GetProcAddress(h,name);
|
||||
if(!p){fprintf(stderr,"Missing export: %s\n",name);exit(2);} return p;
|
||||
}
|
||||
static void dump_vectors(const char *label, float *begin, float *end) {
|
||||
intptr_t bytes=(intptr_t)end-(intptr_t)begin;
|
||||
if(bytes==0){printf("%s VERTICES 0 (animation-only base may be empty)\n",label);return;}
|
||||
if(!begin || bytes<=0 || bytes%16 || bytes>16000000){
|
||||
fprintf(stderr,"Unexpected %s vectors: %p..%p (%ld bytes)\n",label,begin,end,(long)bytes);exit(3);
|
||||
}
|
||||
float lo[3]={FLT_MAX,FLT_MAX,FLT_MAX},hi[3]={-FLT_MAX,-FLT_MAX,-FLT_MAX};
|
||||
for(float *p=begin;p<end;p+=4)for(int i=0;i<3;i++){
|
||||
if(!isfinite(p[i])){fprintf(stderr,"Nonfinite %s coordinate\n",label);exit(3);}
|
||||
if(p[i]<lo[i])lo[i]=p[i];
|
||||
if(p[i]>hi[i])hi[i]=p[i];
|
||||
}
|
||||
printf("%s VERTICES %ld\n",label,(long)bytes/16);
|
||||
printf("%s MIN %.9g %.9g %.9g MAX %.9g %.9g %.9g\n",label,lo[0],lo[1],lo[2],hi[0],hi[1],hi[2]);
|
||||
for(int i=0;i<3 && begin+i*4<end;i++)printf("%s V%d %.9g %.9g %.9g\n",label,i,begin[i*4],begin[i*4+1],begin[i*4+2]);
|
||||
}
|
||||
static uint32_t fingerprint(const unsigned char *p, unsigned count) {
|
||||
uint32_t result=2166136261u;
|
||||
for(unsigned i=0;i<count;i++)result=(result^p[i])*16777619u;
|
||||
return result;
|
||||
}
|
||||
int main(int argc,char **argv) {
|
||||
setbuf(stdout,NULL);
|
||||
const char *input=argc>1?argv[1]:"ASE\\jimstop.ase";
|
||||
int object_mode=argc>2?atoi(argv[2]):2,animation_mode=argc>3?atoi(argv[3]):2;
|
||||
if(object_mode<0 || object_mode>2 || animation_mode<0 || animation_mode>3)return 2;
|
||||
FILE *f=fopen(input,"rb");if(!f){perror(input);return 2;}
|
||||
fseek(f,0,SEEK_END);long length=ftell(f);rewind(f);
|
||||
if(length<=0 || length>64000000){fclose(f);return 2;}
|
||||
char *data=malloc(length);if(!data || fread(data,1,length,f)!=(size_t)length){fclose(f);return 2;}fclose(f);
|
||||
HMODULE h=LoadLibraryA("Z:\\work\\game\\OMT2.dll");
|
||||
if(!h){fprintf(stderr,"LoadLibrary OMT error %lu\n",GetLastError());return 2;}
|
||||
printf("PROBE MODES object=%d animation=%d input=%s\n",object_mode,animation_mode,input);
|
||||
magnitudefn magnitude=(magnitudefn)required(h,"?quick_magnitude@OMedia3DVector@@QBEMXZ");
|
||||
float vectors[][4]={{0,0,0,0},{10,0,0,0},{3,4,0,0},{-4,0,-3,0},{1,1,1,0},
|
||||
{500,100,300,0},{.25f,.125f,.75f,0},{1.2345f,678.125f,-90.75f,0}};
|
||||
for(unsigned i=0;i<sizeof(vectors)/sizeof(vectors[0]);i++){
|
||||
union {float f;uint32_t u;} value;value.f=magnitude(vectors[i]);
|
||||
printf("QUICK_MAG %.9g %.9g %.9g = %.9g BITS %08lx\n",vectors[i][0],vectors[i][1],vectors[i][2],value.f,(unsigned long)value.u);
|
||||
}
|
||||
/* Preferred OMT2 VAs10141E30 and10161E38; module-relative offsets allow ASLR. */
|
||||
printf("SINE_TABLE_FNV32 %08lx HALF_ACOS_TABLE_FNV32 %08lx\n",
|
||||
(unsigned long)fingerprint((const unsigned char*)h+0x141e30,16384*4),
|
||||
(unsigned long)fingerprint((const unsigned char*)h+0x161e38,16384*2));
|
||||
registerfn register_object=(registerfn)required(h,"?register_object@OMediaDataBase@@SAXKP6APAVOMediaDBObject@@XZJ@Z");
|
||||
register_object(0x33445368,(builderfn)required(h,"?db_builder@OMedia3DShape@@SAPAVOMediaDBObject@@XZ"),0);
|
||||
register_object(0x4133646d,(builderfn)required(h,"?db_builder@OMedia3DMorphAnimDef@@SAPAVOMediaDBObject@@XZ"),0);
|
||||
register_object(0x33444d61,(builderfn)required(h,"?db_builder@OMedia3DMaterial@@SAPAVOMediaDBObject@@XZ"),0);
|
||||
register_object(0x43616e76,(builderfn)required(h,"?db_builder@OMediaCanvas@@SAPAVOMediaDBObject@@XZ"),0);
|
||||
unsigned char *stream=calloc(1,8192),*database_stream=calloc(1,8192),*database=calloc(1,8192),*converter=calloc(1,8192);
|
||||
ctor0 memctor=(ctor0)required(h,"??0OMediaMemStream@@QAE@XZ");
|
||||
memctor(stream);memctor(database_stream);
|
||||
((writefn)required(h,"?write@OMediaStream@@UAEXPAXK@Z"))(stream,data,length);
|
||||
((seekfn)required(h,"?setposition@OMediaStream@@UAEXKF@Z"))(stream,0,0);
|
||||
puts("DATABASE_BEGIN");
|
||||
((dbctor)required(h,"??0OMediaDataBase@@QAE@PAVOMediaStream@@@Z"))(database,database_stream);
|
||||
getfn get=(getfn)required(h,"?get_object@OMediaDataBase@@UAEPAVOMediaDBObject@@KJ@Z");
|
||||
unsigned char *shape=get(database,0x33445368,0);
|
||||
if(!shape){fputs("No database shape\n",stderr);return 3;}
|
||||
printf("DATABASE_SHAPE %p DATABASE_LINK %p\n",shape,*(void**)(shape+0x1c));
|
||||
if(*(void**)(shape+0x1c)!=database){fputs("Shape not attached to in-memory database\n",stderr);return 3;}
|
||||
*(int*)required(h,"?obj_conv_mode@OMedia3DShapeConverter@@1W4omt_3DObjectConvertMode@@A")=object_mode;
|
||||
*(int*)required(h,"?anim_conv_mode@OMedia3DShapeConverter@@1W4omt_3DAnimConvertMode@@A")=animation_mode;
|
||||
((converterctor)required(h,"??0OMediaASEConverter@@QAE@PAVOMediaStreamOperators@@PAVOMedia3DShape@@@Z"))(converter,stream,shape);
|
||||
puts("CONVERT_BEGIN");
|
||||
((convertfn)required(h,"?convert@OMediaASEConverter@@UAEXXZ"))(converter);
|
||||
puts("CONVERT_END");
|
||||
dump_vectors("SHAPE",*(float**)(shape+0x68),*(float**)(shape+0x6c));
|
||||
if(*(float**)(shape+0x68)!=*(float**)(shape+0x6c))
|
||||
printf("SHAPE CENTER %.9g %.9g %.9g RADIUS %.9g\n",*(float*)(shape+0x3c),*(float*)(shape+0x40),*(float*)(shape+0x44),*(float*)(shape+0x4c));
|
||||
unsigned char *related=(unsigned char*)required(h,"?related_morphdefs@OMedia3DShapeConverter@@2V?$vector@JV?$allocator@J@std@@@std@@A");
|
||||
long *ids=*(long**)(related+4),*ids_end=*(long**)(related+8);
|
||||
intptr_t id_bytes=(intptr_t)ids_end-(intptr_t)ids;
|
||||
if(id_bytes<0 || id_bytes%4 || id_bytes>4096){fputs("Invalid related morph IDs\n",stderr);return 3;}
|
||||
printf("MORPH_DEFINITIONS %ld\n",(long)id_bytes/4);
|
||||
for(long *id=ids;id<ids_end;id++){
|
||||
unsigned char *db_object=get(database,0x4133646d,*id);
|
||||
if(!db_object){fputs("Missing morph definition\n",stderr);return 3;}
|
||||
/* get_object returns the builder's complete pointer in this DLL. Some
|
||||
* paths expose its virtual-base table; accept only the proven layouts. */
|
||||
uintptr_t table=*(uintptr_t*)db_object;
|
||||
unsigned displacement=table==(uintptr_t)h+0x114304?0:table==(uintptr_t)h+0x1142f8?0x38:0xffffffffu;
|
||||
if(displacement==0xffffffffu){fprintf(stderr,"Unexpected morph vtable %p\n",(void*)table);return 3;}
|
||||
printf("DATABASE_OBJECT_DISPLACEMENT %u\n",displacement);
|
||||
unsigned char *definition=db_object-displacement;
|
||||
unsigned char **sequences=*(unsigned char***)(definition+0x28),**sequences_end=*(unsigned char***)(definition+0x2c);
|
||||
intptr_t sequence_bytes=(intptr_t)sequences_end-(intptr_t)sequences;
|
||||
if(sequence_bytes<0 || sequence_bytes%4 || sequence_bytes>16384){fputs("Invalid sequence table\n",stderr);return 3;}
|
||||
printf("MORPH_ID %ld SEQUENCES %ld\n",*id,(long)sequence_bytes/4);
|
||||
for(unsigned char **sequence=sequences;sequence<sequences_end;sequence++){
|
||||
unsigned char *sentinel=*(unsigned char**)(*sequence+4),*node=*(unsigned char**)sentinel;
|
||||
unsigned frame_count=*(unsigned*)(*sequence+8),frame_index=0;
|
||||
if(frame_count>4096){fputs("Invalid frame count\n",stderr);return 3;}
|
||||
printf("SEQUENCE_%ld FRAMES %u\n",(long)(sequence-sequences),frame_count);
|
||||
while(node!=sentinel && frame_index<frame_count){
|
||||
unsigned char *p=*(unsigned char**)(node+8);
|
||||
char label[64];snprintf(label,sizeof(label),"SEQUENCE_%ld_FRAME_%u",(long)(sequence-sequences),frame_index);
|
||||
printf("%s OFFSET %.9g %.9g %.9g\n",label,*(float*)(p+8),*(float*)(p+0xc),*(float*)(p+0x10));
|
||||
dump_vectors(label,*(float**)(p+0x2c),*(float**)(p+0x30));
|
||||
node=*(unsigned char**)node;frame_index++;
|
||||
}
|
||||
if(node!=sentinel || frame_index!=frame_count){fputs("Frame list count mismatch\n",stderr);return 3;}
|
||||
}
|
||||
}
|
||||
printf("POSTLOAD_STATIC radius=60 factor=%.9g clearance=%.9g\n",1.265f,60.0f*1.265f);
|
||||
puts("PROBE_COMPLETE");
|
||||
/* Process exit releases probe-only objects; no source/database is flushed. */
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user