Page 5 of 7

Re: BSP Quake Editor - source code?

Posted: Sat Mar 03, 2012 1:32 am
by andrewj
reckless wrote:btw source allready makes use of GPL code (libpng jpeg and zlib) so i think it should be ok :)
Those libraries are not GPL :wink:

Re: BSP Quake Editor - source code?

Posted: Sat Mar 03, 2012 3:40 am
by revelator
osi license compatible with gpl my bad its a damn jungle out there :lol:

Re: BSP Quake Editor - source code?

Posted: Sat Mar 03, 2012 6:38 pm
by revelator
anyone had time to test it yet ?

Re: BSP Quake Editor - source code?

Posted: Sun Mar 04, 2012 12:45 am
by qbism
reckless wrote:anyone had time to test it yet ?
Even after disabling CPU optimizations, it's crashing on my Win7 64-bit i3 machine. Usual map load readout is per screenshot below, eXXXX/bXXXX. Normally even a large map loads quickly. The current CB version is stuck on e1/bXXXX (second screenshot) and "b" increments slowly up to around 2,000 and then locks up. Also, textures are not shown.
Image

Image

Re: BSP Quake Editor - source code?

Posted: Sun Mar 04, 2012 8:07 am
by andrewj
reckless wrote:ill upload my source + built executables for testing (im kinda interrested in finding out if it crashes anywhere else) the source has a C::B workspace.

http://code.google.com/p/realm/download ... z&can=2&q=
Where's the source?

That download package only contained an exe.

Re: BSP Quake Editor - source code?

Posted: Sun Mar 04, 2012 10:54 am
by revelator
inside the archive :) its double packed the exe inside is just another 7 zip archive selfextracting.

Re: BSP Quake Editor - source code?

Posted: Sun Mar 04, 2012 10:57 am
by revelator
can you provide me with a test map jeff ? also try and run the debug exe through gdb ill do the same.

it loads here and pretty fast to so im a bit stumped.

Re: BSP Quake Editor - source code?

Posted: Sun Mar 04, 2012 11:59 am
by revelator
gah i feel a bit stupid now remember i couldnt load textures from pak ? well it turns out the feature is only for Q2

Code: Select all

void TTextureWindow::ScanNewWalFromPak(bool prompt)
{
    const char err_title[] = "BSP Scan Pak";

    if (!set.Map_Read)
        return;

    map *m = map_i[set.curmap];
    if (!m)
        return;

    char dirname[256] = "";

    if (prompt)
    {
        char filename[256];

        OPENFILENAME ofn;
        memset(&ofn, 0, sizeof(OPENFILENAME));
        ofn.lStructSize = OPENFILENAMESTRUCTSIZE;
        ofn.hwndOwner = frame->hwnd;
        ofn.lpstrFilter = "Pak files (*.pak)\0*.pak\0";
        ofn.lpstrDefExt = "pak";
        ofn.lpstrFile = filename;
        ofn.nMaxFile = 256;
        ofn.lpstrTitle = "Select Quake 2 Pak0.Pak File";
        ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;

        if (!set.pakOk)
        {
            *filename = 0;
        }
        else
        {
            strncpy(filename, set.pak_file, sizeof(filename));
        }

        if(!GetOpenFileName(&ofn))
            return;

        STRNCPY(dirname,filename);
    }
    else
    {
        if (!set.pakOk)
            return;

        STRNCPY(dirname,set.pak_file);
    }

    // check that it's a .pak file...
    if (!file_exists(dirname))
    {
        sprintf(dirname, "Pak file does not exist [%s]...", dirname);
        MessageBox(hwnd, dirname, err_title, MB_OK | MB_ICONEXCLAMATION);
        return;
    }

    FILE        *f;
    pakheader_t pakheader;
    pakentry_t  *pakentry;
    int			numentries;
    int         i;

    f = fopen(dirname,"rb");
    if (!f)
    {
        sprintf(dirname,"Unable to open pak file\n%s",dirname);
        MessageBox(hwnd,dirname,err_title,MB_OK | MB_ICONEXCLAMATION);
        return;
    }

    fread(&pakheader,sizeof(pakheader_t),1,f);
    if (strnicmp((char *)pakheader.magic,"PACK",4))
    {
        fclose(f);
        sprintf(dirname,"[%s] is not a valid pak file...",dirname);
        MessageBox(hwnd,dirname,err_title,MB_OK | MB_ICONEXCLAMATION);
        return;
    }

    numentries = pakheader.dirsize / (sizeof(pakentry_t));
    fseek(f,pakheader.diroffset,SEEK_SET);

    pakentry = new pakentry_t[numentries];
    for (i=0; i<numentries; i++)
        fread(&pakentry[i],sizeof(pakentry_t),1,f);

    fclose(f);
    pakentry_t *e;

    textureEntry firstEntry;

    memset(&firstEntry,0,sizeof(textureEntry));

    char **EntryList;
    int maxEntries = 64; // maximum texture dirs...
    int EntrySize = 64;
    int curEntries = 0;
    EntryList = new char *[maxEntries];
    memset(EntryList,0,maxEntries*sizeof(char *));
    for (i = 0; i < maxEntries; i++)
    {
        EntryList[i] = new char[EntrySize];
        memset(EntryList[i],0,EntrySize * sizeof(char));
    }

    int left, right, current;
    int done, index;
    int testVal;
    char dir[256];
    char *start;
    int c = numentries;
    int ct;
    for (i= 0 ; i < c ; i++)
    {
        e = &pakentry[i];
        start = (char *)e->filename;

        if (strnicmp(start,"textures",8))
            continue;

        start += strlen("textures");
//verify dir separator
        if(*start != '/' && *start != '\\')
            continue;

        start++;

        STRNCPY(dir,start);
        start = dir;
        ct = 0;
        while (*start && *start != '\\' && *start != '/' && ct++ <= 32)
            start++;

        if (ct >= 32)  // problem, so skip...
            continue;

//verify dir separator
        if(*start != '/' && *start != '\\')
            continue;

        *start = 0;

        left = 0;        // first
        right = curEntries;   //last+1 // never gets tested...

        done = 0;
        index = -1;

        current = (left+right)/2;

        while (!done)
        {
            char *tP = EntryList[current];

            testVal = strcmpi(dir,tP);
            // check for exact match...
            if (testVal == 0)
            {
                index = current;
                break;
            }
            else if (testVal > 0)
            {
                left = current;
                current = (left+right)/2;
            }
            else if (testVal < 0)
            {
                right = current;
                current = (left+right)/2;
            }
            if ((right - left) <= 1)
            {
                if (!strcmpi(dir,EntryList[left]))
                {
                    index = left;
                }
                done = 1;
            }
        }

        if (index >= 0) // if found it, then skip
            continue;

        if (index == -1)   // not found, just insert
        {
            if (curEntries == 0)   // empty list, put in first slot
            {
                strcpy(EntryList[curEntries++],dir);
            }
            else
            {
                int slot = -1;
                int w;
                int tVal;

                for (w = 0; w < curEntries; w++)
                {
                    tVal = strcmpi(dir,EntryList[w]);
                    if (tVal < 0)
                    {
                        slot = w;
                        break;
                    }
                }
                if (slot == -1)
                    slot = curEntries;  // put at end...

                for (w = curEntries; w > slot; w--)
                    strcpy(EntryList[w], EntryList[w-1]);

                strcpy(EntryList[slot],dir);
                curEntries++;
            }
        }
    }

    if (curEntries <= 0)
    {
        sprintf(dirname,"No subdirectories in pak [%s]...",dirname);
        MessageBox(hwnd, dirname, err_title, MB_OK | MB_ICONEXCLAMATION);
        delete[] pakentry;
        for (i = 0; i < maxEntries; i++)
            delete[] EntryList[i];
        delete[] EntryList;
        return;
    }

    TScanTransferBuffer x;
    x.Directory.Clear();
    *x.caption = 0;

    for (i = 0; i < curEntries; i++)
        x.Directory.Add(EntryList[i]);


    TScanDlg dialog(hwnd,&x);
    int retval = dialog.Execute();
    if (retval == IDOK)
    {
        strncpy(dir,x.selected,sizeof(dir));

        texWad *Wad = QueryWadLoaded(dir);  // scan through list!

        // if found it, just change to it...
        if (!Wad)
        {
            Wad = new texWad;
            strncpy(Wad->currentWad,dir,sizeof(Wad->currentWad)); // may get overwritten anyway...
            Wad->WadType   = QUAKE_WAD;
            Wad->bmpsCount = 0;
            Wad->textures  = NULL;
            Wad->nextWad 	= firstWad;
            firstWad 		= Wad;
            currentWadPtr 	= Wad;
            LoadPakDirectory(dir,dirname); // load it in...
        }
        m->Wads[m->numWads++] = Wad;

        UnloadTextures();

        SetUpMap(m);
        ChangeToMap(m);

        sprintf(dirname,"Directory [%s] scanned...",dir);

        set.redrawxy = 1;
        set.redrawedit = 1;
        Show_Frame(dirname,true);
        prevIndex = 0;
        ResetDefaults();
        RedrawContents();
    }

    delete[] pakentry;
    for (i = 0; i < maxEntries; i++)
        delete[] EntryList[i];
    delete[] EntryList;
}
i think ill add a check for Q2 game and print it to screen if someone tries to use it with Q1 then exit gracefully.
better yet make a function that actually can handle Q1.

Re: BSP Quake Editor - source code?

Posted: Sun Mar 04, 2012 3:43 pm
by revelator
wonder if the function could be modified to search for episodes like e1m1 from bsp contents ?.
gdb sadly yielded no problems here :S which version of my gcc are you using ? latest is 4.6.2 earlier versions could have some quirks i fixed later on.
also i havent tried if it compiles with standard mingw might be worth a try :)

Re: BSP Quake Editor - source code?

Posted: Mon Mar 05, 2012 6:50 pm
by r00k
I tried to load a .map file and it locks up each exe. :(

Re: BSP Quake Editor - source code?

Posted: Tue Mar 06, 2012 2:07 am
by qbism
reckless wrote:can you provide me with a test map jeff ? also try and run the debug exe through gdb ill do the same.

it loads here and pretty fast to so im a bit stumped.
I'm loading this .map http://www.quaddicted.com/reviews/apsp2.html
I used texmex to extract the wad from the bsp, which is here temporarily http://qbism.com/_extfiles/apsp2-wad.7z
Debug exe also not working.

Re: BSP Quake Editor - source code?

Posted: Tue Mar 06, 2012 4:13 am
by revelator
thanks jeff. yup this map also crashes here (hangs). though older versions decompiled from quake works :s maybe we are hitting a limit here ? bsp is loading > 60 mb on this map before crashing ouch.
rook does the debug exe also lock up ?

Re: BSP Quake Editor - source code?

Posted: Tue Mar 06, 2012 4:35 am
by revelator
uh spoke to soon it actually loads just takes about 5 mins and allmost 100mb ram

Image

Re: BSP Quake Editor - source code?

Posted: Tue Mar 06, 2012 5:03 am
by r00k
SEEMS TO BE WORKING AFTER a reboot.

Re: BSP Quake Editor - source code?

Posted: Tue Mar 06, 2012 5:29 am
by revelator
Oo ok thats strange.
found out what causes the immense load times though. its the mms library so removing it from build (only used it for testing delete vs delete [] allocations anyway which it rocks at i might add :) ).
if you need it for bug checking add #include "mss.h" to global.h and link against libmss.a.
btw i forgot to include bspupd96.exe you can still get it from the bsp site. its used to convert old bsp ini files to the new version.