static void VerifyTagReferenceFieldDefinition(const tag_field& field,
        const tag_block_definition* block_definition)
{
    auto* definition = field.Definition<tag_reference_definition>();
    YELO_ASSERT_DISPLAY(definition, "no definition specified for tag reference field in block %s.",
                        block_definition->name); // NOTE: added owner block name to info
    YELO_ASSERT( VALID_FLAGS(definition->flags, Flags::k_number_of_tag_group_tag_reference_flags) );

    group_tag_to_string gt_string;
    gt_string.Terminate();

    if(definition->group_tag != NONE)
    {
        gt_string.group = definition->group_tag;
        YELO_ASSERT_DISPLAY( blam::tag_group_get(definition->group_tag),
                             "invalid group tag '%s' for tag reference field '%s' in block %s",
                             gt_string.TagSwap().str, field.name, block_definition->name);
        YELO_ASSERT( definition->group_tags==nullptr );

        TagGroupMarkAsReferenced(definition->group_tag);
    }
    else if(definition->group_tags != nullptr)
    {
        for(auto group_tag : *definition)
        {
            gt_string.group = group_tag;
            YELO_ASSERT_DISPLAY( blam::tag_group_get(group_tag),
                                 "invalid group tag '%s' for variable tag reference field '%s' in block %s",
                                 gt_string.TagSwap().str, field.name, block_definition->name);

            TagGroupMarkAsReferenced(group_tag);
        }
    }
}
static void VerifyDataFieldDefinition(const tag_field& field,
                                      const tag_block_definition* block_definition)
{
    auto* definition = field.Definition<tag_data_definition>();
    YELO_ASSERT_DISPLAY(definition, "no definition specified for tag_data field in block %s.",
                        block_definition->name); // NOTE: added owner block name to info
    YELO_ASSERT( definition->name );
    YELO_ASSERT( VALID_FLAGS(definition->flags, Flags::k_number_of_tag_data_definition_flags) );
    YELO_ASSERT( definition->maximum_size>0 );
}
void c_tag_fieldset_replacement_builder::NextSourceField(bool copy_current_field_first)
{
    YELO_ASSERT( !CurrentSourceFieldIsTerminator() );

    if(copy_current_field_first)
    {
        YELO_ASSERT(m_target_fields_cursor < m_target_fields_max_count);
        tag_field* dst=			&m_target_fields[m_target_fields_cursor++];
        const tag_field* src=	&m_source_fields[m_source_fields_cursor];
        memcpy_s(dst, sizeof(*dst), src, sizeof(*src));
    }

    scanner.Scan();
    ++m_source_fields_cursor;
}
void VerifyGroupFieldDefinitions()
{
    struct verify_group_field_definitions_action
    {
        bool m_found_group_missing_header_definition;

        verify_group_field_definitions_action() : m_found_group_missing_header_definition(false) { }

        void operator()(const tag_group* group)
        {
            if(group->header_block_definition != nullptr)
                VerifyBlockFieldDefinitions(group->header_block_definition);
            else
            {   // NOTE: added this warning
                YELO_WARN("tag group '%s' doesn't have a definition", group->name);
                m_found_group_missing_header_definition = true;
            }
        }
    };

    auto action = verify_group_field_definitions_action();
    TagGroups::tag_groups_do_action(action);

    if(action.m_found_group_missing_header_definition)
    {
        YELO_ASSERT( !"fix your goddamn tag groups" );
    }
}
Exemplo n.º 5
0
		bool game_time_get_paused()
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals);

			return game_time_globals->paused;
		}
Exemplo n.º 6
0
		game_time_t local_time_get_elapsed()
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals && game_time_globals->initialized);

			return game_time_globals->elapsed_time;
		}
Exemplo n.º 7
0
		game_ticks_t game_time_get()
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals && game_time_globals->initialized);

			return game_time_globals->game_time;
		}
Exemplo n.º 8
0
		void game_time_set_speed(float speed)
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals);

			game_time_globals->game_speed = speed;
		}
Exemplo n.º 9
0
		float game_time_get_speed()
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals);

			return game_time_globals->game_speed;
		}
void VerifyBlockFieldDefinitions(tag_block_definition* block)
{
    YELO_ASSERT( block );
    YELO_ASSERT( block->name );
    YELO_ASSERT( VALID_FLAGS(block->flags, Flags::k_number_of_tag_block_definition_flags) );
    YELO_ASSERT( block->maximum_element_count>=0 );
    YELO_ASSERT( CAST(int,block->element_size)>=0 );
    YELO_ASSERT( block->fields );

    struct verify_tag_field_action
    {   void operator()(const tag_block_definition* block, const tag_field& field) const
        {
            VerifyTagField(block, field);
        }
    };

    block->FieldsDoAction<verify_tag_field_action, true>();
}
c_tag_fieldset_replacement_builder::c_tag_fieldset_replacement_builder(
    const tag_field* source_fields,
    tag_field* target_fields, int target_fields_size, int target_fields_count)
    :
    m_source_fields( source_fields ),
    m_source_fields_cursor( 0 ),

    m_target_fields( target_fields ),
    m_target_fields_cursor( 0 ),
    m_target_fields_max_count( target_fields_size ),

    m_available_pad_size( NONE ),
    scanner(source_fields, NULL)
{
    YELO_ASSERT( source_fields != NULL );
    YELO_ASSERT( target_fields != NULL && target_fields_size > 0 );
    // the target fields shouldn't be initialized yet
    YELO_ASSERT( target_fields_count == 0 );

    scanner.AddAllFieldTypes();
}
Exemplo n.º 12
0
		void game_time_set_paused(bool paused)
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals);

			if (game_time_globals->initialized)
			{
				game_time_globals->active = !paused;
			}

			game_time_globals->paused = paused;
		}
Exemplo n.º 13
0
		bool game_in_progress()
		{
			auto game_time_globals = GameState::GameTimeGlobals();
			YELO_ASSERT(game_time_globals);

			if (game_time_globals->initialized)
			{
				return game_time_globals->active || game_time_globals->paused;
			}

			return false;
		}
		void c_animation_fixups::InitializeAnimationIndexArrayFixups()
		{
			importer_animation_index_array = YELO_NEW_ARRAY(int32, max_animations);
			YELO_ASSERT( importer_animation_index_array );

			void* IMPORTER_ANIMATION_INDEX_SET_INDICE_HOOK = CAST_PTR(void*, 0x404415);
			Memory::WriteRelativeJmp(_importer_animation_index_set_indice, 
				IMPORTER_ANIMATION_INDEX_SET_INDICE_HOOK, true);

			void* IMPORTER_ANIMATION_INDEX_SET_INDICE2_HOOK = CAST_PTR(void*, 0x404452);
			Memory::WriteRelativeJmp(_importer_animation_index_set_indice2, 
				IMPORTER_ANIMATION_INDEX_SET_INDICE2_HOOK, true);
		}
		void c_animation_fixups::InitializeAnimationRemappingIndexArrayFixups()
		{
			importer_animation_remapping_index_array = YELO_NEW_ARRAY(int16, max_animations);
			YELO_ASSERT( importer_animation_remapping_index_array );
			memset(importer_animation_remapping_index_array, NONE, max_animations * sizeof(importer_animation_remapping_index_array[0]));

			void* IMPORTER_ANIMATION_REMAPPING_INDEX_SET_INDICE_HOOK = CAST_PTR(void*, 0x403326);
			Memory::WriteRelativeJmp(_importer_animation_remapping_index_set_indice, 
				IMPORTER_ANIMATION_REMAPPING_INDEX_SET_INDICE_HOOK, true);

			void* IMPORTER_ANIMATION_REMAPPING_INDEX_GET_INDICE_HOOK = CAST_PTR(void*, 0x4033AF);
			Memory::WriteRelativeJmp(_importer_animation_remapping_index_get_indice, 
				IMPORTER_ANIMATION_REMAPPING_INDEX_GET_INDICE_HOOK, true);

			void* IMPORTER_ANIMATION_REMAPPING_INDEX_GET_INDICE2_HOOK = CAST_PTR(void*, 0x40349D);
			Memory::WriteRelativeJmp(_importer_animation_remapping_index_get_indice2, 
				IMPORTER_ANIMATION_REMAPPING_INDEX_GET_INDICE2_HOOK, true);
		}
void VerifyTagField(const tag_block_definition* block_definition, const tag_field& field)
{
    switch(field.type)
    {
    case Enums::_field_string:
    {
        uintptr_t definition = CAST_PTR(uintptr_t, field.definition);

        YELO_ASSERT( definition==0 || definition <= Enums::k_long_string_length ||
                     TagFieldIsOldStringId(&field) );
    }
    break;

    case Enums::_field_enum:
        VerifyEnumFieldDefinition<int16>(field, block_definition);
        break;

    case Enums::_field_long_flags:
        VerifyFlagsFieldDefinition<long_flags>(field, block_definition);
        break;
    case Enums::_field_word_flags:
        VerifyFlagsFieldDefinition<word_flags>(field, block_definition);
        break;
    case Enums::_field_byte_flags:
        VerifyFlagsFieldDefinition<byte_flags>(field, block_definition);
        break;

    case Enums::_field_tag_reference:
        VerifyTagReferenceFieldDefinition(field, block_definition);
        break;

    case Enums::_field_block:
    {
        auto* definition = field.Definition<tag_block_definition>();
        YELO_ASSERT_DISPLAY(definition, "no definition specified for block field in block %s.",
                            block_definition->name); // NOTE: added owner block name to info

        VerifyBlockFieldDefinitions(definition);
    }
    break;

    case Enums::_field_data:
        VerifyDataFieldDefinition(field, block_definition);
        break;

    case Enums::_field_short_block_index:
    case Enums::_field_long_block_index:
    {
        auto* definition = field.Definition<tag_block_definition>();
        YELO_ASSERT_DISPLAY(definition, "no definition specified for block index field in block %s.",
                            block_definition->name); // NOTE: added owner block name to info
    }
    break;

    case Enums::_field_array_start:
    case Enums::_field_pad:
    case Enums::_field_skip:
        YELO_ASSERT( CAST_PTR(int32,field.definition)>0 );
        break;

    case Enums::_field_explanation:
    {
        cstring definition = field.Definition<const char>();
        YELO_ASSERT_DISPLAY(definition, "no definition specified for explanation field in block %s.",
                            block_definition->name); // NOTE: added owner block name to info
    }
    break;
    }
}