Here's an example:
You want to hook Host_ValidSave()
Look at the linux decompile or regamedll
Code:
int Host_ValidSave(void)
{
if (cmd_source != src_command)
return 0;
if (!g_psv.active)
{
Con_Printf("Not playing a local game.\n");
return 0;
}
if (g_psvs.maxclients != 1)
{
Con_Printf("Can't save multiplayer games.\n");
return 0;
}
if (g_pcls.state != ca_active || g_pcls.signon != 2)
{
Con_Printf("Can't save during transition.\n");
return 0;
}
if (g_pcl.intermission)
{
Con_Printf("Can't save in intermission.\n");
return 0;
}
if (g_psvs.clients->active && g_psvs.clients->edict->v.health <= 0.0)
{
Con_Printf("Can't savegame with a dead player\n");
return 0;
}
return 1;
}
Search for those same strings in the Windows decompile, and you have your function, sub_1D479C0().
Code:
signed int __cdecl sub_1D479C0()
{
signed int result; // eax@3
if ( dword_269A21C != 1 )
return 0;
if ( !dword_21D4A00 )
{
sub_1D2C030("Not playing a local game.\n");
return 0;
}
if ( *(_DWORD *)dword_21D3E88 != 1 )
{
sub_1D2C030("Can't save multiplayer games.\n");
return 0;
}
if ( dword_26EBA80 != 5 || *(_DWORD *)dword_26EEF9C != 2 )
{
sub_1D2C030("Can't save during transition.\n");
return 0;
}
if ( dword_271D200 )
{
sub_1D2C030("Can't save in intermission.\n");
result = 0;
}
else
{
if ( *(_DWORD *)dword_21D3E84 && *(float *)(*(_DWORD *)(dword_21D3E84 + 19356) + 480) <= 0.0 )
{
sub_1D2C030("Can't savegame with a dead player\n");
result = 0;
}
else
{
result = 1;
}
}
return result;
}
__________________