Ejemplo n.º 1
0
uint32 parseVersion(String version)
{
  Array<String> sub;
  if (!version.match("(\\d+)\\.(\\d+)([b-z]?)", &sub))
    return 0;
  int major = sub[1].toInt();
  int minor = sub[2].toInt();
  int build = 0;
  if (!sub[3].empty())
    build = int(sub[3][0] - 'a');
  return makeVersion(major, minor, build);
}
Ejemplo n.º 2
0
void CSearchDlg::OnOK ()
{
  ss.ffunc = mode[BOX_FILE].GetCurSel ();
  GetDlgItemText (IDC_FTEXT, ss.ftext, 256);
  ss.nfunc = mode[BOX_NAME].GetCurSel ();
  GetDlgItemTextW (m_hWnd, IDC_NTEXT, ss.ntext, 256);
  ss.mfunc = mode[BOX_MODE].GetCurSel ();
  GetDlgItemText (IDC_MTEXT, ss.mtext, 256);
  for (int i = 0; i < 5; i++)
  {
    ss.pmode[i] = mode[i].GetCurSel ();
    ss.phero[i] = hero[i].GetItemDataEx (selhero[i]);
  }
  GetDlgItemTextW (m_hWnd, IDC_PNAME1, ss.pname[0], 256);
  GetDlgItemTextW (m_hWnd, IDC_PNAME2, ss.pname[1], 256);
  GetDlgItemTextW (m_hWnd, IDC_PNAME3, ss.pname[2], 256);
  GetDlgItemTextW (m_hWnd, IDC_PNAME4, ss.pname[3], 256);
  GetDlgItemTextW (m_hWnd, IDC_PNAME5, ss.pname[4], 256);

  char buf[256];
  BOOL trans;

  GetDlgItemText (IDC_COUNTA, buf, 256);
  if (buf[0] == 0)
    ss.numa = 0;
  else
  {
    ss.numa = GetDlgItemInt (IDC_COUNTA, &trans, FALSE);
    if (trans == FALSE)
    {
      MessageBox ("Invalid minimal player number!", "Error", MB_OK | MB_ICONHAND);
      GetDlgItem (IDC_COUNTA)->SetFocus ();
      return;
    }
  }

  GetDlgItemText (IDC_COUNTB, buf, 256);
  if (buf[0] == 0)
    ss.numb = 16;
  else
  {
    ss.numb = GetDlgItemInt (IDC_COUNTB, &trans, FALSE);
    if (trans == FALSE)
    {
      MessageBox ("Invalid maximal player number!", "Error", MB_OK | MB_ICONHAND);
      GetDlgItem (IDC_COUNTB)->SetFocus ();
      return;
    }
  }

  GetDlgItemText (IDC_VERSIONA, buf, 256);
  if (buf[0] == 0)
    ss.vera = 0;
  else
  {
    ss.vera = makeVersion (buf);
    if (ss.vera == 0)
    {
      MessageBox ("Invalid minimal map version!", "Error", MB_OK | MB_ICONHAND);
      GetDlgItem (IDC_VERSIONA)->SetFocus ();
      return;
    }
  }

  GetDlgItemText (IDC_VERSIONB, buf, 256);
  if (buf[0] == 0)
    ss.verb = GC_BIGINT;
  else
  {
    ss.verb = makeVersion (buf);
    if (ss.verb == 0)
    {
      MessageBox ("Invalid maximal map version!", "Error", MB_OK | MB_ICONHAND);
      GetDlgItem (IDC_VERSIONB)->SetFocus ();
      return;
    }
  }

  GetDlgItemText (IDC_PATCHA, buf, 256);
  if (buf[0] == 0)
    ss.pata = 0;
  else
  {
    ss.pata = makeVersion (buf, true);
    if (ss.pata == 0)
    {
      MessageBox ("Invalid minimal patch version!", "Error", MB_OK | MB_ICONHAND);
      GetDlgItem (IDC_PATCHA)->SetFocus ();
      return;
    }
  }

  GetDlgItemText (IDC_PATCHB, buf, 256);
  if (buf[0] == 0)
    ss.patb = GC_BIGINT;
  else
  {
    ss.patb = makeVersion (buf, true);
    if (ss.patb == 0)
    {
      MessageBox ("Invalid maximal patch version!", "Error", MB_OK | MB_ICONHAND);
      GetDlgItem (IDC_PATCHB)->SetFocus ();
      return;
    }
  }

  CTime ts;

  lfrom.GetTime (ts);
  ss.lena = ((ts.GetHour () * 60 + ts.GetMinute ()) * 60 + ts.GetSecond ()) * 1000;
  lto.GetTime (ts);
  ss.lenb = ((ts.GetHour () * 60 + ts.GetMinute ()) * 60 + ts.GetSecond ()) * 1000;
  dfrom.GetTime (ts);
  ss.sava = CTime (ts.GetYear (), ts.GetMonth (), ts.GetDay (), 0, 0, 0).GetTime ();
  dto.GetTime (ts);
  ss.savb = CTime (ts.GetYear (), ts.GetMonth (), ts.GetDay (), 23, 59, 59).GetTime ();

  CDialog::OnOK ();
}
Ejemplo n.º 3
0
Application::Application(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MPQInit();
    instance = this;
    resources = NULL;
    imageLibrary = NULL;
    dotaLibrary = NULL;
    mainWindow = NULL;
    cache = NULL;
    hInstance = _hInstance;
    _loaded = false;

    root = String::getPath(getAppPath());
    cfg.read();

    warLoader = new MPQLoader("Custom_V1");
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3.mpq"));
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3x.mpq"));
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3xlocal.mpq"));
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3patch.mpq"));

    if (logCommand(lpCmdLine))
        return;

    ScriptType::initTypes();
    UpdateDialog::init(hInstance);

    INITCOMMONCONTROLSEX iccex;
    iccex.dwSize = sizeof iccex;
    iccex.dwICC = ICC_STANDARD_CLASSES | ICC_PROGRESS_CLASS |
                  ICC_BAR_CLASSES | ICC_TREEVIEW_CLASSES | ICC_LISTVIEW_CLASSES |
                  ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_DATE_CLASSES;
    InitCommonControlsEx(&iccex);
    LoadLibrary("Riched20.dll");
    OleInitialize(NULL);

    String path = String::getPath(getAppPath());
    String resPath = String::buildFullName(path, "resources.mpq");
    String patchPath = String::buildFullName(path, "install.mpq");
    File* tOpen = File::open(resPath, File::READ);
    if (tOpen == NULL)
    {
        tOpen = File::open(patchPath, File::READ);
        if (tOpen)
        {
            delete tOpen;
            MoveFile(patchPath, resPath);
        }
    }
    else
        delete tOpen;
    resources = MPQArchive::open(resPath);
    MPQArchive* patch = MPQArchive::open(patchPath, File::READ);
    if (patch)
    {
        for (uint32 i = 0; i < patch->getHashSize(); i++)
        {
            char const* name = patch->getFileName(i);
            if (name)
            {
                MPQFile* source = patch->openFile(i, File::READ);
                if (source)
                {
                    MPQFile* dest = resources->openFile(name, File::REWRITE);
                    if (dest)
                    {
                        static uint8 buf[1024];
                        while (int length = source->read(buf, sizeof buf))
                            dest->write(buf, length);
                        delete dest;
                    }
                    delete source;
                }
            }
        }
        delete patch;
        DeleteFile(patchPath);
    }

    imageLibrary = new ImageLibrary(resources);

    cache = new CacheManager();
    dotaLibrary = new DotaLibrary();

#if 0
    File* dlog = File::open("diff.txt", File::REWRITE);
    for (int pt = 0; pt < 120; pt++)
    {
        String prev = "";
        bool different = false;
        for (int ver = 1; ver <= 80 && !different; ver++)
        {
            Dota* dota = dotaLibrary->getDota(makeVersion(6, ver));
            if (dota)
            {
                Dota::Hero* hero = dota->getHero(pt);
                if (hero)
                {
                    if (prev == "")
                        prev = hero->name;
                    else if (prev.icompare(hero->name))
                        different = true;
                }
            }
        }
        if (different)
        {
            dlog->printf("  Pt=%d\r\n", pt);
            prev = "";
            for (int ver = 1; ver <= 80; ver++)
            {
                Dota* dota = dotaLibrary->getDota(makeVersion(6, ver));
                if (dota)
                {
                    Dota::Hero* hero = dota->getHero(pt);
                    if (hero)
                    {
                        if (prev.icompare(hero->name))
                        {
                            dlog->printf("6.%02d = %s\r\n", ver, hero->name);
                            prev = hero->name;
                        }
                    }
                }
            }
        }
    }
    delete dlog;
#endif
#if 0
    dotaLibrary->getDota(parseVersion("6.79e"),
                         "K:\\Progs\\DotAReplay\\maps\\DotA v6.79e.w3x");
    WIN32_FIND_DATA data;
    String enumPath = "K:\\Progs\\DotAReplay\\maps";
    HANDLE hFind = FindFirstFile(String::buildFullName(enumPath, "*"), &data);
    BOOL success = (hFind != INVALID_HANDLE_VALUE);
    while (success)
    {
        String file(data.cFileName);
        if (String::getExtension(file).icompare(".w3x") == 0)
        {
            file.toLower();
            Array<String> sub;
            if (file.rfind("dota{{_| }allstars}?{_| }v(\\d)\\.(\\d\\d)([b-z]?)[^b-z]", 0, &sub) >= 0)
            {
                int major = sub[1].toInt();
                int minor = sub[2].toInt();
                int build = 0;
                if (!sub[3].isEmpty())
                    build = int(sub[3][0] - 'a');
                uint32 version = makeVersion(major, minor, build);

                dotaLibrary->getDota(version, String::buildFullName(enumPath, file));
            }
        }
        success = FindNextFile(hFind, &data);
    }
    FindClose(hFind);
#endif

    mainWindow = new MainWnd();

    mainWindow->postLoad();
    _loaded = true;

    if (lpCmdLine[0])
    {
        COPYDATASTRUCT cd;
        cd.dwData = MAINWND_OPEN_REPLAY;
        cd.cbData = strlen(lpCmdLine) + 1;
        cd.lpData = lpCmdLine;
        PostMessage(getMainWindow(), WM_COPYDATA_FAKE, NULL, (LPARAM) &cd);
    }
}