Exemplo n.º 1
0
FileNode_t CFileList::createNodeInfo(string szFilePath)
{
	FileNode_t	node;

	InitNode(node);
    char fpath[1024];
    sprintf(fpath, "%s",szFilePath.data());
    
    node.filepath=fpath;
    
    
     CheckPlatform(node, szFilePath);

	return node;
}
Exemplo n.º 2
0
        void UpdateAI(uint32 const diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_CHILLING_BREATH:
                        DoCastRandom(SPELL_CHILLING_BREATH, 0.0f);
                        events.ScheduleEvent(EVENT_CHILLING_BREATH, urand(7500, 12500));
                        break;
                    case EVENT_CALL_THE_WIND:
                    {
                        if (Creature *c = me->FindNearestCreature(NPC_WIND, 100))
                            c->DespawnOrUnsummon();
                        instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_WIND_OF_ALTAIRUS);
                        instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_DOWNWIND_OF_ALTAIRUS);
                        instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_UPWIND_OF_ALTAIRUS);
                        events.ScheduleEvent(EVENT_CALL_THE_WIND, urand(14000, 19000));
                        events.ScheduleEvent(EVENT_CALL_THE_WIND_POST, 2000);
                        break;
                    }
                    case EVENT_CALL_THE_WIND_POST:
                    {
                        Talk(EMOTE_WINDS);
                        float orientation = 0.0f;
                        switch (rand() % 4)
                        {
                            case 0:
                                orientation = M_PI / 2;
                                break;
                            case 1:
                                orientation = M_PI;
                                break;
                            case 2:
                                orientation = 3 * M_PI / 2;
                                break;
                            case 3:
                                orientation = 2 * M_PI;
                                break;
                            default:
                                orientation = M_PI;
                                break;
                        }
                        me->SummonCreature(NPC_WIND, -1213.83f, 62.99f, 734.2f, orientation, TEMPSUMMON_MANUAL_DESPAWN);
                        WindOfAltairus();
                        events.CancelEvent(EVENT_CALL_THE_WIND_POST);
                        break;
                    }
                    case EVENT_LIGHTNING_BLAST:
                        CheckPlatform();
                        events.ScheduleEvent(EVENT_LIGHTNING_BLAST, 5000);
                        break;
                    default:
                        break;
                }
            }

            DoMeleeAttackIfReady();
        }
Exemplo n.º 3
0
void DoUserDialog(char* filename)
{
    tFlashInfo FlashInfo;
    char buf[32];
    char default_filename[32];
    int button;
    int rc; /* generic return code */
    size_t memleft;
    tCheckROM result;
    bool is_romless;

    /* this can only work if Rockbox runs in DRAM, not flash ROM */
    if ((UINT8*)rb >= FB && (UINT8*)rb < FB + 4096*1024) /* 4 MB max */
    {   /* we're running from flash */
        rb->splash(HZ*3, "Not from ROM");
        return; /* exit */
    }

    /* test if the user is running the correct plugin for this box */
    if (!CheckPlatform(PLATFORM_ID, *(UINT16*)(FB + VERSION_ADR)))
    {
        rb->splash(HZ*3, "Wrong version");
        return; /* exit */
    }

    /* refuse to work if the power may fail meanwhile */
    if (!rb->battery_level_safe())
    {
        rb->splash(HZ*3, "Batt. too low!");
        return; /* exit */
    }
    
    /* check boot ROM */
    result = CheckBootROM();
    if (result == eUnknown)
    {   /* no support for any other yet */
        rb->splash(HZ*3, "Wrong boot ROM");
        return; /* exit */
    }
    is_romless = (result == eROMless);

    /* compose filename if none given */
    if (filename == NULL)
    {
        rb->snprintf(
            default_filename, 
            sizeof(default_filename),
            "/firmware_%s%s.bin",
            FILE_TYPE,
            is_romless ? "_norom" : "");
        filename = default_filename;
    }

    /* "allocate" memory */
    sector = rb->plugin_get_buffer(&memleft);
    if (memleft < SEC_SIZE) /* need buffer for a flash sector */
    {
        rb->splash(HZ*3, "Out of memory");
        return; /* exit */
    }

    rc = GetFlashInfo(&FlashInfo);
    ShowFlashInfo(&FlashInfo);
    
    if (FlashInfo.size == 0) /* no valid chip */
    {
        return; /* exit */
    }
    
    rb->lcd_puts_scroll(0, 0, filename);
    rb->lcd_puts_scroll(0, 1, "[Menu] to check");
    rb->lcd_update();

    button = WaitForButton();
    if (button != BUTTON_MENU)
    {
        return;
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts(0, 0, "Checking...");
    rb->lcd_update();

    rc = CheckFirmwareFile(filename, FlashInfo.size, is_romless);
    rb->lcd_puts(0, 0, "Checked:");
    switch (rc)
    {
    case eOK:
        rb->lcd_puts(0, 1, "File OK.");
        break;
    case eFileNotFound:
        rb->lcd_puts_scroll(0, 0, "File not found:");
        rb->lcd_puts_scroll(0, 1, filename);
        break;
    case eTooBig:
        rb->lcd_puts_scroll(0, 0, "File too big,");
        rb->lcd_puts_scroll(0, 1, "larger than chip.");
        break;
    case eTooSmall:
        rb->lcd_puts_scroll(0, 0, "File too small.");
        rb->lcd_puts_scroll(0, 1, "Incomplete?");
        break;
    case eReadErr:
        rb->lcd_puts_scroll(0, 0, "Read error.");
        break;
    case eBadContent:
        rb->lcd_puts_scroll(0, 0, "File invalid.");
        rb->lcd_puts_scroll(0, 1, "Sanity check failed.");
        break;
    case eCrcErr:
        rb->lcd_puts_scroll(0, 0, "File invalid.");
        rb->lcd_puts_scroll(0, 1, "CRC check failed.");
        break;
    case eBadPlatform:
        rb->lcd_puts_scroll(0, 0, "Wrong file for");
        rb->lcd_puts_scroll(0, 1, "this hardware.");
        break;
    default:
        rb->lcd_puts_scroll(0, 0, "Check failed.");
        break;
    }
    rb->lcd_update();

    rb->sleep(HZ*3);

    if (rc == eOK)
    {
        rb->lcd_puts_scroll(0, 0, "[On] to program,");
        rb->lcd_puts_scroll(0, 1, "other key to exit.");
        rb->lcd_update();
    }
    else
    {   /* error occured */
        return;
    }
    
    button = WaitForButton();

    if (button != BUTTON_ON)
    {
        return;
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Are you sure?");
    rb->lcd_puts_scroll(0, 1, "[+] to proceed.");
    rb->lcd_update();

    button = WaitForButton();
    
    if (button != BUTTON_RIGHT)
    {
        return;
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Programming...");
    rb->lcd_update();

    rc = ProgramFirmwareFile(filename, FlashInfo.size);
    
    if (rc)
    {   /* errors */
        rb->lcd_clear_display();
        rb->lcd_puts_scroll(0, 0, "Programming failed!");
        rb->snprintf(buf, sizeof(buf), "%d errors", rc);
        rb->lcd_puts_scroll(0, 1, buf);
        rb->lcd_update();
        WaitForButton();
    }
    
    rb->lcd_clear_display();
    rb->lcd_puts_scroll(0, 0, "Verifying...");
    rb->lcd_update();

    rc = VerifyFirmwareFile(filename);
    
    rb->lcd_clear_display();
    
    if (rc == 0)
    {
        rb->lcd_puts_scroll(0, 0, "Verify OK.");
    }
    else
    {
        rb->snprintf(buf, sizeof(buf), "Verify failed! %d errors", rc);
        rb->lcd_puts_scroll(0, 0, buf);
    }

    rb->lcd_puts_scroll(0, 1, "Press any key to exit.");
    rb->lcd_update();
    WaitForButton();
}
Exemplo n.º 4
0
        void UpdateAI(const uint32 diff)
        {
            CheckPlatform();

            if (isWaitingForPhase)
                return;

            if (!UpdateVictim())
                return;

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            events.Update(diff);

            switch (events.ExecuteEvent())
            {
            // All Phases
            case EVENT_DOT_ATTACK:
            {
                if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO))
                    me->CastSpell(target, dotSpellId, false);

                events.ScheduleEvent(EVENT_DOT_ATTACK, 12500);
                break;
            }
            case EVENT_RE_ATTACK:
            {
                if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO))
                    me->GetMotionMaster()->MoveChase(target);

                me->SetReactState(REACT_AGGRESSIVE);
                break;
            }
            // Fist Phase
            case EVENT_LIGHTNING_FISTS:
            {
                me->CastSpell(me, SPELL_LIGHTNING_FISTS, false);
                events.ScheduleEvent(EVENT_LIGHTNING_FISTS, 20000);
                break;
            }
            case EVENT_EPICENTER:
            {
                me->MonsterTextEmote("Feng the Accursed begins to channel a violent Epicenter !", 0, true);
                me->CastSpell(me, SPELL_EPICENTER, false);
                events.ScheduleEvent(EVENT_EPICENTER, 35000);
                break;
            }
            // Spear Phase
            case EVENT_WILDFIRE_SPARK:
            {
                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                {
                    me->MonsterTextEmote("You have been affected by Wildfire Spark !", target->GetGUID(), true);
                    me->CastSpell(target, SPELL_WILDFIRE_SPARK, false);
                }
                events.ScheduleEvent(EVENT_WILDFIRE_SPARK, urand(25000, 35000));
                break;
            }
            case EVENT_DRAW_FLAME:
            {
                me->MonsterTextEmote("Feng the Accursed begins to Draw Flame to his weapon !", 0, true);
                me->CastSpell(me, SPELL_DRAW_FLAME, false);

                events.ScheduleEvent(EVENT_DRAW_FLAME, 60000);
                break;
            }
            // Staff Phase
            case EVENT_ARCANE_VELOCITY:
            {
                me->SetSpeed(MOVE_RUN, 0.0f);
                me->CastSpell(me, SPELL_ARCANE_VELOCITY, false);
                events.ScheduleEvent(EVENT_ARCANE_VELOCITY_END, 100);   // The eventmap don't update while the creature is casting
                events.ScheduleEvent(EVENT_ARCANE_VELOCITY,     15000);
                break;
            }
            case EVENT_ARCANE_VELOCITY_END:
            {
                me->SetSpeed(MOVE_RUN, 1.14f);
                break;
            }
            case EVENT_ARCANE_RESONANCE:
            {
                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 2))
                    target->AddAura(SPELL_ARCANE_RESONANCE, target);
                events.ScheduleEvent(EVENT_ARCANE_RESONANCE, 40000);
                break;
            }
            // Shield Phase : TODO
            default:
                break;
            }

            DoMeleeAttackIfReady();
        }
Exemplo n.º 5
0
tCheckResult CheckFirmwareFile(char* filename, int chipsize, bool is_romless)
{
    int i;
    int fd;
    int fileleft; /* size info, how many left for reading */
    int fileread = 0; /* total size as read from the file */
    int read_now; /* how many to read for this sector */
    int got_now; /* how many gotten for this sector */
    unsigned crc32 = 0xFFFFFFFF; /* CCITT init value */
    unsigned file_crc; /* CRC value read from file */
    bool has_crc;
    
    fd = rb->open(filename, O_RDONLY);
    if (fd < 0)
        return eFileNotFound;
    
    fileleft = rb->filesize(fd);
    if (fileleft > chipsize)
    {
        rb->close(fd);
        return eTooBig;
    }
    else if (fileleft < 20000) /* give it some reasonable lower limit */
    {
        rb->close(fd);
        return eTooSmall;
    }
    
    if (fileleft == 256*1024)
    {   /* original dumped firmware file has no CRC nor platform ID */
        has_crc = false;
    }
    else
    {
        has_crc = true;
        fileleft -= sizeof(unsigned); /* exclude the last 4 bytes */
    }

    /* do some sanity checks */
    
    got_now = rb->read(fd, sector, SEC_SIZE); /* read first sector */
    fileread += got_now;
    fileleft -= got_now;
    if (got_now != SEC_SIZE)
    {
        rb->close(fd);
        return eReadErr;
    }

    /* version number in file plausible with this hardware? */
    if (!CheckPlatform(PLATFORM_ID, *(UINT16*)(sector + VERSION_ADR)))
    {
        rb->close(fd);
        return eBadPlatform;
    }
    
    if (has_crc)
    {
        crc32 = rb->crc_32(sector, SEC_SIZE, crc32); /* checksum */
        
        /* in addition to the CRC, my files also have a platform ID */
        if (sector[PLATFORM_ADR] != PLATFORM_ID) /* for our hardware? */
        {
            rb->close(fd);
            return eBadPlatform;
        }
    }

    if (is_romless)
    {   /* in this case, there is not much we can check */
        if (*(UINT32*)sector != 0x00000200) /* reset vector */
        {
            rb->close(fd);
            return eBadContent;
        }
    }
    else
    {
        /* compare some bytes which have to be identical */
        if (*(UINT32*)sector != 0x41524348) /* "ARCH" */
        {
            rb->close(fd);
            return eBadContent;
        }
    
        for (i = 0x30; i<MASK_ADR-2; i++) /* leave two bytes for me */
        {
            if (sector[i] != FB[i])
            {
                rb->close(fd);
                return eBadContent;
            }
        }
    }
    
    /* check if we can read the whole file, and do checksum */
    do
    {
        read_now = MIN(SEC_SIZE, fileleft);
        got_now = rb->read(fd, sector, read_now);
        fileread += got_now;
        fileleft -= got_now;

        if (read_now != got_now)
        {
            rb->close(fd);
            return eReadErr;
        }

        if (has_crc)
        {
            crc32 = rb->crc_32(sector, got_now, crc32); /* checksum */
        }
    } while (fileleft);

    if (has_crc)
    {
        got_now = rb->read(fd, &file_crc, sizeof(file_crc));
        if (got_now != sizeof(file_crc))
        {
            rb->close(fd);
            return eReadErr;
        }
    }
    
    /*  must be EOF now */
    got_now = rb->read(fd, sector, SEC_SIZE);
    rb->close(fd);
    if (got_now != 0)
        return eReadErr;

    if (has_crc && file_crc != crc32)
        return eCrcErr;
    
    return eOK;
}