Quote Originally Posted by kung foo man View Post
Based on vorons reversed function, lets just eliminate all possible segfaults (four dereferences of pointers in the if):

PHP Code:
int hook_BG_IsWeaponValid(int a1int a2) {
    
    
int v3;
    
char v4;
    
    
signed int (*sub_80E9758)(int a1);
    *(
int *)&sub_80E9758 0x80E9758;
    
    
int (*sub_80D9E84)(int a1signed int a2);
    *(
int *)&sub_80D9E84 0x80D9E84;
    
    
int (*sub_80E9270)(int a1);
    *(
int *)&sub_80E9270 0x80E9270;

    
v4 1;
    if ( !(
unsigned int8_t)sub_80E9758(a2) )
        
v4 0;
    if ( !(
unsigned int8_t)sub_80D9E84(a1 1348a2) )
        
v4 0;
    
v3 sub_80E9270(a2);
    
    if ((
long *)(v3 132) == NULL)
    {
        
printf("this would later crash 1\n");
        return 
0;
    }
    if ((
char *)(a1 1365) == NULL)
    {
        
printf("this would later crash 2\n");
        return 
0;
    }
    if ((
char *)(a1 1366) == NULL)
    {
        
printf("this would later crash 3\n");
        return 
0;
    }
    if ((
long *)(v3 876) == NULL)
    {
        
printf("this would later crash 4\n");
        return 
0;
    }
    
    if ( !*(
long *)(v3 132) && *(char *)(a1 1365) != a2 && *(char *)(a1 1366) != a2 && *(long *)(v3 876) != a2 )
        
v4 0;
    
    
// printf("Testcall\n");

    
return (unsigned int8_t)v4;

Whoa, thanks. Added and waiting for potential segfault.

Let's imagine that some of these pointers will turn null and function will return 0. What happens next? What does engine do? It pretends like nothing really happened?

Quote Originally Posted by kung foo man View Post
Edit: and if nothing helps, you might even just ignore the segfault: http://stackoverflow.com/questions/8...sigsegv-signal
In case your function doesn't solve the problem, does libcod has it's own signal() function? Or shall I add signal.h to the libcod's repository?