/* Original479D20 with copied code and synthetic ordinary-body virtual contracts. * No game loader/entrypoint, script, audio or real actor instance is executed. */ #define main isolated_kernel_main #include "collision_response_probe.c" #undef main #define TC __attribute__((thiscall)) typedef struct Node {struct Node *next,*previous;void *value;} Node; typedef struct { uintptr_t *table;Vec position,previous,velocity,acceleration,impulse,angular,rotation,anchor; int supported,support,world,pairs,prevent;float speed,friction,factor,radius,scale; unsigned landings;float landing_velocity;int landing_supported; unsigned char reserved[0x500]; // Covers source dispatcher's direct member42C. } Body; typedef void (__cdecl *BodyStep)(Body*,float); static int TC supported(Body*b){return b->supported;} static int TC support(Body*b){return b->support;} static int TC world(Body*b){return b->world;} static int TC pairs(Body*b){return b->pairs;} static int TC yes(Body*b){(void)b;return 1;} static int TC no(Body*b){(void)b;return 0;} static int TC prevent(Body*b){return b->prevent;} static void TC set_supported(Body*b,int value){b->supported=value;} static float TC radius(Body*b){return b->radius;} static float TC factor(Body*b){return b->factor;} static float TC speed(Body*b){return b->speed;} static float TC friction(Body*b){return b->friction;} static float TC scale(Body*b){return b->scale;} #define GET(name,field) static Vec *TC name(Body*b,Vec*out){*out=b->field;return out;} GET(position,position) GET(previous,previous) GET(velocity,velocity) GET(acceleration,acceleration) GET(impulse,impulse) GET(angular,angular) GET(rotation,rotation) #define SET(name,field) static void TC name(Body*b,Vec v){b->field=v;} SET(set_position,position) SET(set_previous,previous) SET(set_velocity,velocity) SET(set_acceleration,acceleration) #define XYZ(name,field) static void TC name(Body*b,float x,float y,float z){b->field.x=x;b->field.y=y;b->field.z=z;} XYZ(position_xyz,position) XYZ(velocity_xyz,velocity) XYZ(acceleration_xyz,acceleration) XYZ(impulse_xyz,impulse) XYZ(angular_xyz,angular) XYZ(anchor_xyz,anchor) #define ADD(name,field) static void TC name(Body*b,float x,float y,float z){b->field.x+=x;b->field.y+=y;b->field.z+=z;} ADD(add_velocity,velocity) ADD(add_angular,angular) ADD(rotate,rotation) static void TC move(Body*b,Vec v){b->position.x+=v.x;b->position.y+=v.y;b->position.z+=v.z;} static void TC landing(Body*b){b->landings++;b->landing_velocity=b->velocity.y;b->landing_supported=b->supported;} static void TC pointer(Body*b,void*p){(void)b;(void)p;} static void TC contact(Body*b,Vec normal,void*p){(void)b;(void)normal;(void)p;} static uintptr_t table[0x500/4]; static void TC missing(Body*b) { (void)b;uintptr_t call=(uintptr_t)__builtin_return_address(0); fprintf(stderr,"MISSING fixture virtual after sourceVA %08lx\n",(unsigned long)(call-(uintptr_t)mapped+0x400000)); ExitProcess(2); } static Node sentinels[2][260*260]; static unsigned char polygon[0x30],shape[0x90],corners[60]; static Vec points[3]={{-1000,0,-1000,1},{1000,0,-1000,1},{0,0,1000,1}}; static void setup(void) { for(unsigned i=0;inext=s->previous=s; *(Node**)AT((g?0x5cfc7c:0x509b24)+i*12)=s; } *(void**)(polygon+0x24)=corners;*(Vec*)(polygon+8)=(Vec){0,1,0,0}; *(void**)(shape+0x68)=points; for(unsigned i=0;i<3;i++)*(unsigned*)(corners+i*20)=i; for(int x=127;x<=132;x++)for(int z=127;z<=132;z++) { Node*s=&sentinels[1][260*x+z],*n=calloc(1,sizeof(Node));void**r=calloc(1,0x1c); require(n&&r,"support fixture allocation");r[0]=polygon;r[1]=shape;n->value=r; n->next=s;n->previous=s->previous;s->previous->next=n;s->previous=n; } *(Vec*)AT(0x5cfc00)=(Vec){0,-800,0,0}; } static Body initial(void) { Body b={0};b.table=table;b.position=(Vec){0,75.9f,0,1};b.previous=b.position; b.support=b.world=b.pairs=b.prevent=1;b.radius=60;b.factor=1.265f;b.friction=.8f;b.scale=.5f; return b; } static void run(const char*name,Body b,int geometry) { *(unsigned char*)AT(0x4f69e5)=geometry; ((BodyStep)AT(0x479d20))(&b,1.0f/60); printf("CASE %s root=%.9g,%.9g,%.9g velocity=%.9g,%.9g,%.9g acceleration=%.9g,%.9g,%.9g impulseY=%.9g angularY=%.9g grounded=%d landings=%u observedVy=%.9g observedSupport=%d\n", name,b.position.x,b.position.y,b.position.z,b.velocity.x,b.velocity.y,b.velocity.z, b.acceleration.x,b.acceleration.y,b.acceleration.z,b.impulse.y,b.angular.y,b.supported, b.landings,b.landing_velocity,b.landing_supported); require(isfinite(b.position.y)&&isfinite(b.velocity.y),"finite source body output"); } int main(void) { setbuf(stdout,NULL);map_copy();setup();Body b=initial(); run("floor_support",b,1); b=initial();b.position.y=26;b.previous=b.position;run("spawn_settle",b,1); b=initial();b.supported=1;b.impulse.y=550;b.acceleration.y=-264;run("pending_jump",b,1); b=initial();b.position.y=100;b.previous=b.position;b.velocity.y=-200;run("fall_above_floor",b,1); b=initial();b.position.y=76;b.previous=b.position;b.velocity.y=-200;run("fall_land",b,1); b=initial();b.velocity=(Vec){100,0,50,0};b.angular.y=12;run("ground_friction",b,1); b=initial();b.velocity=(Vec){100,0,50,0};b.angular.y=12;b.speed=100;run("published_speed",b,1); b=initial();b.angular.y=12;run("stationary_angular",b,1); b=initial();b.velocity.x=.125f;run("small_motion",b,1); b=initial();b.velocity.y=200;b.acceleration.y=-264;run("geometry_disabled",b,0); puts("BODY_COMPONENT_COMPLETE: copied479D20/support with synthetic virtual contracts");return 0; }