コード例 #1
0
ファイル: deh_ptr.c プロジェクト: Azarien/chocolate-doom
static void DEH_PointerSHA1Sum(sha1_context_t *context)
{
    int i;

    for (i=0; i<NUMSTATES; ++i)
    {
        SHA1_UpdateInt32(context, CodePointerIndex(&states[i].action));
    }
}
コード例 #2
0
ファイル: deh_mapping.c プロジェクト: MP2E/chocolate-doom
void DEH_StructSHA1Sum(sha1_context_t *context, deh_mapping_t *mapping,
                       void *structptr)
{
    int i;

    // Go through each mapping

    for (i=0; mapping->entries[i].name != NULL; ++i)
    {
        deh_mapping_entry_t *entry = &mapping->entries[i];
        void *location;

        if (entry->location == NULL)
        {
            // Unsupported field

            continue;
        }

        // Add in data for this field

        location = (uint8_t *)structptr + ((uint8_t *)entry->location - (uint8_t *)mapping->base);

        switch (entry->size)
        {
            case 1:
                SHA1_UpdateInt32(context, *((uint8_t *) location));
                break;
            case 2:
                SHA1_UpdateInt32(context, *((uint16_t *) location));
                break;
            case 4:
                SHA1_UpdateInt32(context, *((uint32_t *) location));
                break;
            default:
                I_Error("Unknown dehacked mapping field type for '%s' (BUG)", 
                        entry->name);
                break;
        }
    }
}